mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge branch 'master' into retry-tx-refractor
This commit is contained in:
commit
81e72147ef
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,5 @@
|
|||||||
npm-debug.log
|
npm-debug.log
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
|
||||||
|
|
||||||
app/bower_components
|
app/bower_components
|
||||||
test/bower_components
|
test/bower_components
|
||||||
@ -32,4 +31,4 @@ ui/app/css/output/
|
|||||||
notes.txt
|
notes.txt
|
||||||
|
|
||||||
.coveralls.yml
|
.coveralls.yml
|
||||||
.nyc_output
|
.nyc_output
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
|
- Fix flashing to Log in screen after logging in or restoring from seed phrase.
|
||||||
|
|
||||||
|
## 4.2.0 Tue Mar 06 2018
|
||||||
|
|
||||||
|
- Replace "Loose" wording to "Imported".
|
||||||
|
- Replace "Unlock" wording with "Log In".
|
||||||
|
- Add Imported Account disclaimer.
|
||||||
- Allow adding custom tokens to classic ui when balance is 0
|
- Allow adding custom tokens to classic ui when balance is 0
|
||||||
- Allow editing of symbol and decimal info when adding custom token in new-ui
|
- Allow editing of symbol and decimal info when adding custom token in new-ui
|
||||||
- NewUI shapeshift form can select all coins (not just BTC)
|
- NewUI shapeshift form can select all coins (not just BTC)
|
||||||
|
- Add most of Microsoft Edge support.
|
||||||
|
|
||||||
## 4.1.3 2018-2-28
|
## 4.1.3 2018-2-28
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "MetaMask",
|
"name": "MetaMask",
|
||||||
"short_name": "Metamask",
|
"short_name": "Metamask",
|
||||||
"version": "4.1.3",
|
"version": "4.2.0",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"author": "https://metamask.io",
|
"author": "https://metamask.io",
|
||||||
"description": "Ethereum Browser Extension",
|
"description": "Ethereum Browser Extension",
|
||||||
@ -59,7 +59,7 @@
|
|||||||
"clipboardWrite",
|
"clipboardWrite",
|
||||||
"http://localhost:8545/",
|
"http://localhost:8545/",
|
||||||
"https://*.infura.io/"
|
"https://*.infura.io/"
|
||||||
],
|
],
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
"scripts/inpage.js"
|
"scripts/inpage.js"
|
||||||
],
|
],
|
||||||
@ -68,4 +68,4 @@
|
|||||||
"https://metamask.io/*"
|
"https://metamask.io/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ const ObservableStore = require('obs-store')
|
|||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const Transaction = require('ethereumjs-tx')
|
const Transaction = require('ethereumjs-tx')
|
||||||
const EthQuery = require('ethjs-query')
|
const EthQuery = require('ethjs-query')
|
||||||
const TransactionStateManger = require('../lib/tx-state-manager')
|
const TransactionStateManager = require('../lib/tx-state-manager')
|
||||||
const TxGasUtil = require('../lib/tx-gas-utils')
|
const TxGasUtil = require('../lib/tx-gas-utils')
|
||||||
const PendingTransactionTracker = require('../lib/pending-tx-tracker')
|
const PendingTransactionTracker = require('../lib/pending-tx-tracker')
|
||||||
const NonceTracker = require('../lib/nonce-tracker')
|
const NonceTracker = require('../lib/nonce-tracker')
|
||||||
@ -37,7 +37,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
this.query = new EthQuery(this.provider)
|
this.query = new EthQuery(this.provider)
|
||||||
this.txGasUtil = new TxGasUtil(this.provider)
|
this.txGasUtil = new TxGasUtil(this.provider)
|
||||||
|
|
||||||
this.txStateManager = new TransactionStateManger({
|
this.txStateManager = new TransactionStateManager({
|
||||||
initState: opts.initState,
|
initState: opts.initState,
|
||||||
txHistoryLimit: opts.txHistoryLimit,
|
txHistoryLimit: opts.txHistoryLimit,
|
||||||
getNetwork: this.getNetwork.bind(this),
|
getNetwork: this.getNetwork.bind(this),
|
||||||
|
48
app/scripts/lib/seed-phrase-verifier.js
Normal file
48
app/scripts/lib/seed-phrase-verifier.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
const KeyringController = require('eth-keyring-controller')
|
||||||
|
|
||||||
|
const seedPhraseVerifier = {
|
||||||
|
|
||||||
|
// Verifies if the seed words can restore the accounts.
|
||||||
|
//
|
||||||
|
// The seed words can recreate the primary keyring and the accounts belonging to it.
|
||||||
|
// The created accounts in the primary keyring are always the same.
|
||||||
|
// The keyring always creates the accounts in the same sequence.
|
||||||
|
verifyAccounts (createdAccounts, seedWords) {
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
if (!createdAccounts || createdAccounts.length < 1) {
|
||||||
|
return reject(new Error('No created accounts defined.'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyringController = new KeyringController({})
|
||||||
|
const Keyring = keyringController.getKeyringClassForType('HD Key Tree')
|
||||||
|
const opts = {
|
||||||
|
mnemonic: seedWords,
|
||||||
|
numberOfAccounts: createdAccounts.length,
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyring = new Keyring(opts)
|
||||||
|
keyring.getAccounts()
|
||||||
|
.then((restoredAccounts) => {
|
||||||
|
|
||||||
|
log.debug('Created accounts: ' + JSON.stringify(createdAccounts))
|
||||||
|
log.debug('Restored accounts: ' + JSON.stringify(restoredAccounts))
|
||||||
|
|
||||||
|
if (restoredAccounts.length !== createdAccounts.length) {
|
||||||
|
// this should not happen...
|
||||||
|
return reject(new Error('Wrong number of accounts'))
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < restoredAccounts.length; i++) {
|
||||||
|
if (restoredAccounts[i].toLowerCase() !== createdAccounts[i].toLowerCase()) {
|
||||||
|
return reject(new Error('Not identical accounts! Original: ' + createdAccounts[i] + ', Restored: ' + restoredAccounts[i]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = seedPhraseVerifier
|
@ -16,7 +16,7 @@ const txStateHistoryHelper = require('./tx-state-history-helper')
|
|||||||
// - `'failed'` the tx failed for some reason, included on tx data.
|
// - `'failed'` the tx failed for some reason, included on tx data.
|
||||||
// - `'dropped'` the tx nonce was already used
|
// - `'dropped'` the tx nonce was already used
|
||||||
|
|
||||||
module.exports = class TransactionStateManger extends EventEmitter {
|
module.exports = class TransactionStateManager extends EventEmitter {
|
||||||
constructor ({ initState, txHistoryLimit, getNetwork }) {
|
constructor ({ initState, txHistoryLimit, getNetwork }) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ const version = require('../manifest.json').version
|
|||||||
const BN = require('ethereumjs-util').BN
|
const BN = require('ethereumjs-util').BN
|
||||||
const GWEI_BN = new BN('1000000000')
|
const GWEI_BN = new BN('1000000000')
|
||||||
const percentile = require('percentile')
|
const percentile = require('percentile')
|
||||||
|
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
|
||||||
|
|
||||||
module.exports = class MetamaskController extends EventEmitter {
|
module.exports = class MetamaskController extends EventEmitter {
|
||||||
|
|
||||||
@ -344,6 +345,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
// primary HD keyring management
|
// primary HD keyring management
|
||||||
addNewAccount: nodeify(this.addNewAccount, this),
|
addNewAccount: nodeify(this.addNewAccount, this),
|
||||||
placeSeedWords: this.placeSeedWords.bind(this),
|
placeSeedWords: this.placeSeedWords.bind(this),
|
||||||
|
verifySeedPhrase: nodeify(this.verifySeedPhrase, this),
|
||||||
clearSeedWordCache: this.clearSeedWordCache.bind(this),
|
clearSeedWordCache: this.clearSeedWordCache.bind(this),
|
||||||
resetAccount: this.resetAccount.bind(this),
|
resetAccount: this.resetAccount.bind(this),
|
||||||
importAccountWithStrategy: this.importAccountWithStrategy.bind(this),
|
importAccountWithStrategy: this.importAccountWithStrategy.bind(this),
|
||||||
@ -565,14 +567,18 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
// Opinionated Keyring Management
|
// Opinionated Keyring Management
|
||||||
//
|
//
|
||||||
|
|
||||||
async addNewAccount (cb) {
|
async addNewAccount () {
|
||||||
const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
|
const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
|
||||||
if (!primaryKeyring) return cb(new Error('MetamaskController - No HD Key Tree found'))
|
if (!primaryKeyring) {
|
||||||
|
throw new Error('MetamaskController - No HD Key Tree found')
|
||||||
|
}
|
||||||
const keyringController = this.keyringController
|
const keyringController = this.keyringController
|
||||||
const oldAccounts = await keyringController.getAccounts()
|
const oldAccounts = await keyringController.getAccounts()
|
||||||
const keyState = await keyringController.addNewAccount(primaryKeyring)
|
const keyState = await keyringController.addNewAccount(primaryKeyring)
|
||||||
const newAccounts = await keyringController.getAccounts()
|
const newAccounts = await keyringController.getAccounts()
|
||||||
|
|
||||||
|
await this.verifySeedPhrase()
|
||||||
|
|
||||||
newAccounts.forEach((address) => {
|
newAccounts.forEach((address) => {
|
||||||
if (!oldAccounts.includes(address)) {
|
if (!oldAccounts.includes(address)) {
|
||||||
this.preferencesController.setSelectedAddress(address)
|
this.preferencesController.setSelectedAddress(address)
|
||||||
@ -587,14 +593,43 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
// Used when creating a first vault, to allow confirmation.
|
// Used when creating a first vault, to allow confirmation.
|
||||||
// Also used when revealing the seed words in the confirmation view.
|
// Also used when revealing the seed words in the confirmation view.
|
||||||
placeSeedWords (cb) {
|
placeSeedWords (cb) {
|
||||||
|
|
||||||
|
this.verifySeedPhrase()
|
||||||
|
.then((seedWords) => {
|
||||||
|
this.configManager.setSeedWords(seedWords)
|
||||||
|
return cb(null, seedWords)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
return cb(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifies the current vault's seed words if they can restore the
|
||||||
|
// accounts belonging to the current vault.
|
||||||
|
//
|
||||||
|
// Called when the first account is created and on unlocking the vault.
|
||||||
|
async verifySeedPhrase () {
|
||||||
|
|
||||||
const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
|
const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
|
||||||
if (!primaryKeyring) return cb(new Error('MetamaskController - No HD Key Tree found'))
|
if (!primaryKeyring) {
|
||||||
primaryKeyring.serialize()
|
throw new Error('MetamaskController - No HD Key Tree found')
|
||||||
.then((serialized) => {
|
}
|
||||||
const seedWords = serialized.mnemonic
|
|
||||||
this.configManager.setSeedWords(seedWords)
|
const serialized = await primaryKeyring.serialize()
|
||||||
cb(null, seedWords)
|
const seedWords = serialized.mnemonic
|
||||||
})
|
|
||||||
|
const accounts = await primaryKeyring.getAccounts()
|
||||||
|
if (accounts.length < 1) {
|
||||||
|
throw new Error('MetamaskController - No accounts found')
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await seedPhraseVerifier.verifyAccounts(accounts, seedWords)
|
||||||
|
return seedWords
|
||||||
|
} catch (err) {
|
||||||
|
log.error(err.message)
|
||||||
|
throw err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearSeedWordCache
|
// ClearSeedWordCache
|
||||||
|
@ -7,12 +7,13 @@ const changelogPath = path.join(__dirname, '..', 'CHANGELOG.md')
|
|||||||
const manifestPath = path.join(__dirname, '..', 'app', 'manifest.json')
|
const manifestPath = path.join(__dirname, '..', 'app', 'manifest.json')
|
||||||
const manifest = require('../app/manifest.json')
|
const manifest = require('../app/manifest.json')
|
||||||
const versionBump = require('./version-bump')
|
const versionBump = require('./version-bump')
|
||||||
|
|
||||||
const bumpType = normalizeType(process.argv[2])
|
const bumpType = normalizeType(process.argv[2])
|
||||||
|
|
||||||
|
start().catch(console.error)
|
||||||
|
|
||||||
readFile(changelogPath)
|
async function start() {
|
||||||
.then(async (changeBuffer) => {
|
|
||||||
|
const changeBuffer = await readFile(changelogPath)
|
||||||
const changelog = changeBuffer.toString()
|
const changelog = changeBuffer.toString()
|
||||||
|
|
||||||
const newData = await versionBump(bumpType, changelog, manifest)
|
const newData = await versionBump(bumpType, changelog, manifest)
|
||||||
@ -22,10 +23,8 @@ readFile(changelogPath)
|
|||||||
await writeFile(changelogPath, newData.changelog)
|
await writeFile(changelogPath, newData.changelog)
|
||||||
await writeFile(manifestPath, manifestString)
|
await writeFile(manifestPath, manifestString)
|
||||||
|
|
||||||
return newData.version
|
console.log(`Bumped ${bumpType} to version ${newData.version}`)
|
||||||
})
|
}
|
||||||
.then((version) => console.log(`Bumped ${bumpType} to version ${version}`))
|
|
||||||
.catch(console.error)
|
|
||||||
|
|
||||||
|
|
||||||
function normalizeType (userInput) {
|
function normalizeType (userInput) {
|
||||||
|
@ -34,10 +34,7 @@ AccountImportSubview.prototype.render = function () {
|
|||||||
const { type } = state
|
const { type } = state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
h('div', {
|
h('div', [
|
||||||
style: {
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
h('.section-title.flex-row.flex-center', [
|
h('.section-title.flex-row.flex-center', [
|
||||||
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
||||||
onClick: (event) => {
|
onClick: (event) => {
|
||||||
@ -46,6 +43,27 @@ AccountImportSubview.prototype.render = function () {
|
|||||||
}),
|
}),
|
||||||
h('h2.page-subtitle', 'Import Accounts'),
|
h('h2.page-subtitle', 'Import Accounts'),
|
||||||
]),
|
]),
|
||||||
|
h('.error', {
|
||||||
|
style: {
|
||||||
|
display: 'inline-block',
|
||||||
|
alignItems: 'center',
|
||||||
|
padding: '5px 15px 0px 15px',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
h('span', 'Imported accounts will not be associated with your originally created MetaMask account seedphrase. Learn more about imported accounts '),
|
||||||
|
h('span', {
|
||||||
|
style: {
|
||||||
|
color: 'rgba(247, 134, 28, 1)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
textDecoration: 'underline',
|
||||||
|
},
|
||||||
|
onClick: () => {
|
||||||
|
global.platform.openWindow({
|
||||||
|
url: 'https://metamask.helpscoutdocs.com/article/17-what-are-loose-accounts',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}, 'here.'),
|
||||||
|
]),
|
||||||
h('div', {
|
h('div', {
|
||||||
style: {
|
style: {
|
||||||
padding: '10px',
|
padding: '10px',
|
||||||
|
@ -79,7 +79,7 @@ class AccountDropdowns extends Component {
|
|||||||
try { // Sometimes keyrings aren't loaded yet:
|
try { // Sometimes keyrings aren't loaded yet:
|
||||||
const type = keyring.type
|
const type = keyring.type
|
||||||
const isLoose = type !== 'HD Key Tree'
|
const isLoose = type !== 'HD Key Tree'
|
||||||
return isLoose ? h('.keyring-label', 'LOOSE') : null
|
return isLoose ? h('.keyring-label', 'IMPORTED') : null
|
||||||
} catch (e) { return }
|
} catch (e) { return }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ hr.horizontal-line {
|
|||||||
background: rgba(255,0,0,0.8);
|
background: rgba(255,0,0,0.8);
|
||||||
color: white;
|
color: white;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
left: -8px;
|
left: -18px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
min-width: 20px;
|
min-width: 20px;
|
||||||
|
@ -69,7 +69,7 @@ UnlockScreen.prototype.render = function () {
|
|||||||
style: {
|
style: {
|
||||||
margin: 10,
|
margin: 10,
|
||||||
},
|
},
|
||||||
}, 'Unlock'),
|
}, 'Log In'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
h('.flex-row.flex-center.flex-grow', [
|
h('.flex-row.flex-center.flex-grow', [
|
||||||
|
22511
package-lock.json
generated
Normal file
22511
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@
|
|||||||
"dist": "npm run dist:clear && npm install && gulp dist",
|
"dist": "npm run dist:clear && npm install && gulp dist",
|
||||||
"dist:clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/eth-phishing-detect",
|
"dist:clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/eth-phishing-detect",
|
||||||
"test": "npm run lint && npm run test:coverage && npm run test:integration",
|
"test": "npm run lint && npm run test:coverage && npm run test:integration",
|
||||||
"test:unit": "METAMASK_ENV=test mocha --exit --compilers js:babel-core/register --require test/helper.js --recursive \"test/unit/**/*.js\"",
|
"test:unit": "METAMASK_ENV=test mocha --exit --require babel-core/register --require test/helper.js --recursive \"test/unit/**/*.js\"",
|
||||||
"test:single": "METAMASK_ENV=test mocha --require test/helper.js",
|
"test:single": "METAMASK_ENV=test mocha --require test/helper.js",
|
||||||
"test:integration": "gulp build:scss && npm run test:flat && npm run test:mascara",
|
"test:integration": "gulp build:scss && npm run test:flat && npm run test:mascara",
|
||||||
"test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload",
|
"test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload",
|
||||||
@ -222,7 +222,7 @@
|
|||||||
"jsdom": "^11.1.0",
|
"jsdom": "^11.1.0",
|
||||||
"jsdom-global": "^3.0.2",
|
"jsdom-global": "^3.0.2",
|
||||||
"jshint-stylish": "~2.2.1",
|
"jshint-stylish": "~2.2.1",
|
||||||
"karma": "^1.7.1",
|
"karma": "^2.0.0",
|
||||||
"karma-chrome-launcher": "^2.2.0",
|
"karma-chrome-launcher": "^2.2.0",
|
||||||
"karma-cli": "^1.0.1",
|
"karma-cli": "^1.0.1",
|
||||||
"karma-firefox-launcher": "^1.0.1",
|
"karma-firefox-launcher": "^1.0.1",
|
||||||
|
1374
test/stub/blacklist.json
Normal file
1374
test/stub/blacklist.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -38,4 +38,4 @@ describe('blacklist controller', function () {
|
|||||||
assert.equal(result, false)
|
assert.equal(result, false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const MessageManger = require('../../app/scripts/lib/message-manager')
|
const MessageManager = require('../../app/scripts/lib/message-manager')
|
||||||
|
|
||||||
describe('Message Manager', function () {
|
describe('Message Manager', function () {
|
||||||
let messageManager
|
let messageManager
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
messageManager = new MessageManger()
|
messageManager = new MessageManager()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#getMsgList', function () {
|
describe('#getMsgList', function () {
|
||||||
|
@ -1,129 +1,103 @@
|
|||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const sinon = require('sinon')
|
const sinon = require('sinon')
|
||||||
const clone = require('clone')
|
const clone = require('clone')
|
||||||
|
const nock = require('nock')
|
||||||
const MetaMaskController = require('../../app/scripts/metamask-controller')
|
const MetaMaskController = require('../../app/scripts/metamask-controller')
|
||||||
|
const blacklistJSON = require('../stub/blacklist')
|
||||||
const firstTimeState = require('../../app/scripts/first-time-state')
|
const firstTimeState = require('../../app/scripts/first-time-state')
|
||||||
const BN = require('ethereumjs-util').BN
|
|
||||||
const GWEI_BN = new BN('1000000000')
|
|
||||||
|
|
||||||
describe('MetaMaskController', function () {
|
describe('MetaMaskController', function () {
|
||||||
const noop = () => {}
|
let metamaskController
|
||||||
const metamaskController = new MetaMaskController({
|
const sandbox = sinon.sandbox.create()
|
||||||
showUnconfirmedMessage: noop,
|
const noop = () => { }
|
||||||
unlockAccountMessage: noop,
|
|
||||||
showUnapprovedTx: noop,
|
|
||||||
platform: {},
|
|
||||||
encryptor: {
|
|
||||||
encrypt: function(password, object) {
|
|
||||||
this.object = object
|
|
||||||
return Promise.resolve()
|
|
||||||
},
|
|
||||||
decrypt: function () {
|
|
||||||
return Promise.resolve(this.object)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// initial state
|
|
||||||
initState: clone(firstTimeState),
|
|
||||||
})
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// sinon allows stubbing methods that are easily verified
|
|
||||||
this.sinon = sinon.sandbox.create()
|
nock('https://api.infura.io')
|
||||||
|
.persist()
|
||||||
|
.get('/v2/blacklist')
|
||||||
|
.reply(200, blacklistJSON)
|
||||||
|
|
||||||
|
nock('https://api.infura.io')
|
||||||
|
.persist()
|
||||||
|
.get(/.*/)
|
||||||
|
.reply(200)
|
||||||
|
|
||||||
|
metamaskController = new MetaMaskController({
|
||||||
|
showUnapprovedTx: noop,
|
||||||
|
encryptor: {
|
||||||
|
encrypt: function (password, object) {
|
||||||
|
this.object = object
|
||||||
|
return Promise.resolve()
|
||||||
|
},
|
||||||
|
decrypt: function () {
|
||||||
|
return Promise.resolve(this.object)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
initState: clone(firstTimeState),
|
||||||
|
})
|
||||||
|
sandbox.spy(metamaskController.keyringController, 'createNewVaultAndKeychain')
|
||||||
|
sandbox.spy(metamaskController.keyringController, 'createNewVaultAndRestore')
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
// sinon requires cleanup otherwise it will overwrite context
|
nock.cleanAll()
|
||||||
this.sinon.restore()
|
sandbox.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Metamask Controller', function () {
|
describe('#getGasPrice', function () {
|
||||||
assert(metamaskController)
|
it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () {
|
||||||
|
const realRecentBlocksController = metamaskController.recentBlocksController
|
||||||
beforeEach(function () {
|
metamaskController.recentBlocksController = {
|
||||||
sinon.spy(metamaskController.keyringController, 'createNewVaultAndKeychain')
|
store: {
|
||||||
sinon.spy(metamaskController.keyringController, 'createNewVaultAndRestore')
|
getState: () => {
|
||||||
})
|
return {
|
||||||
|
recentBlocks: [
|
||||||
afterEach(function () {
|
{ gasPrices: [ '0x3b9aca00', '0x174876e800'] },
|
||||||
metamaskController.keyringController.createNewVaultAndKeychain.restore()
|
{ gasPrices: [ '0x3b9aca00', '0x174876e800'] },
|
||||||
metamaskController.keyringController.createNewVaultAndRestore.restore()
|
{ gasPrices: [ '0x174876e800', '0x174876e800' ]},
|
||||||
})
|
{ gasPrices: [ '0x174876e800', '0x174876e800' ]},
|
||||||
|
],
|
||||||
describe('#getGasPrice', function () {
|
|
||||||
it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () {
|
|
||||||
const realRecentBlocksController = metamaskController.recentBlocksController
|
|
||||||
metamaskController.recentBlocksController = {
|
|
||||||
store: {
|
|
||||||
getState: () => {
|
|
||||||
return {
|
|
||||||
recentBlocks: [
|
|
||||||
{ gasPrices: [ '0x3b9aca00', '0x174876e800'] },
|
|
||||||
{ gasPrices: [ '0x3b9aca00', '0x174876e800'] },
|
|
||||||
{ gasPrices: [ '0x174876e800', '0x174876e800' ]},
|
|
||||||
{ gasPrices: [ '0x174876e800', '0x174876e800' ]},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
const gasPrice = metamaskController.getGasPrice()
|
const gasPrice = metamaskController.getGasPrice()
|
||||||
assert.equal(gasPrice, '0x3b9aca00', 'accurately estimates 50th percentile accepted gas price')
|
assert.equal(gasPrice, '0x3b9aca00', 'accurately estimates 50th percentile accepted gas price')
|
||||||
|
|
||||||
metamaskController.recentBlocksController = realRecentBlocksController
|
|
||||||
})
|
|
||||||
|
|
||||||
it('gives the 1 gwei price if no blocks have been seen.', async function () {
|
|
||||||
const realRecentBlocksController = metamaskController.recentBlocksController
|
|
||||||
metamaskController.recentBlocksController = {
|
|
||||||
store: {
|
|
||||||
getState: () => {
|
|
||||||
return {
|
|
||||||
recentBlocks: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const gasPrice = metamaskController.getGasPrice()
|
|
||||||
assert.equal(gasPrice, '0x' + GWEI_BN.toString(16), 'defaults to 1 gwei')
|
|
||||||
|
|
||||||
metamaskController.recentBlocksController = realRecentBlocksController
|
|
||||||
})
|
|
||||||
|
|
||||||
|
metamaskController.recentBlocksController = realRecentBlocksController
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('#createNewVaultAndKeychain', function () {
|
describe('#createNewVaultAndKeychain', function () {
|
||||||
it('can only create new vault on keyringController once', async function () {
|
it('can only create new vault on keyringController once', async function () {
|
||||||
const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
|
const selectStub = sandbox.stub(metamaskController, 'selectFirstIdentity')
|
||||||
|
|
||||||
|
const password = 'a-fake-password'
|
||||||
|
|
||||||
const password = 'a-fake-password'
|
await metamaskController.createNewVaultAndKeychain(password)
|
||||||
|
await metamaskController.createNewVaultAndKeychain(password)
|
||||||
|
|
||||||
const first = await metamaskController.createNewVaultAndKeychain(password)
|
assert(metamaskController.keyringController.createNewVaultAndKeychain.calledOnce)
|
||||||
const second = await metamaskController.createNewVaultAndKeychain(password)
|
|
||||||
|
|
||||||
assert(metamaskController.keyringController.createNewVaultAndKeychain.calledOnce)
|
selectStub.reset()
|
||||||
|
|
||||||
selectStub.reset()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('#createNewVaultAndRestore', function () {
|
describe('#createNewVaultAndRestore', function () {
|
||||||
it('should be able to call newVaultAndRestore despite a mistake.', async function () {
|
it('should be able to call newVaultAndRestore despite a mistake.', async function () {
|
||||||
// const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
|
|
||||||
|
|
||||||
const password = 'what-what-what'
|
const password = 'what-what-what'
|
||||||
const wrongSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadiu'
|
const wrongSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadiu'
|
||||||
const rightSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
|
const rightSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
|
||||||
const first = await metamaskController.createNewVaultAndRestore(password, wrongSeed)
|
await metamaskController.createNewVaultAndRestore(password, wrongSeed)
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
const second = await metamaskController.createNewVaultAndRestore(password, rightSeed)
|
await metamaskController.createNewVaultAndRestore(password, rightSeed)
|
||||||
|
|
||||||
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
|
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,25 +1,38 @@
|
|||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
const nock = require('nock')
|
||||||
const NetworkController = require('../../app/scripts/controllers/network')
|
const NetworkController = require('../../app/scripts/controllers/network')
|
||||||
|
|
||||||
|
const { createTestProviderTools } = require('../stub/provider')
|
||||||
|
const providerResultStub = {}
|
||||||
|
const provider = createTestProviderTools({ scaffold: providerResultStub }).provider
|
||||||
|
|
||||||
describe('# Network Controller', function () {
|
describe('# Network Controller', function () {
|
||||||
let networkController
|
let networkController
|
||||||
|
const noop = () => {}
|
||||||
const networkControllerProviderInit = {
|
const networkControllerProviderInit = {
|
||||||
getAccounts: () => {},
|
getAccounts: noop,
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
|
nock('https://api.infura.io')
|
||||||
|
.get('/*/')
|
||||||
|
.reply(200)
|
||||||
|
|
||||||
|
nock('https://rinkeby.infura.io')
|
||||||
|
.post('/metamask')
|
||||||
|
.reply(200)
|
||||||
|
|
||||||
networkController = new NetworkController({
|
networkController = new NetworkController({
|
||||||
provider: {
|
provider,
|
||||||
type: 'rinkeby',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
|
networkController.initializeProvider(networkControllerProviderInit, provider)
|
||||||
})
|
})
|
||||||
describe('network', function () {
|
describe('network', function () {
|
||||||
describe('#provider', function () {
|
describe('#provider', function () {
|
||||||
it('provider should be updatable without reassignment', function () {
|
it('provider should be updatable without reassignment', function () {
|
||||||
networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
|
networkController.initializeProvider(networkControllerProviderInit, provider)
|
||||||
const proxy = networkController._proxy
|
const proxy = networkController._proxy
|
||||||
proxy.setTarget({ test: true, on: () => {} })
|
proxy.setTarget({ test: true, on: () => {} })
|
||||||
assert.ok(proxy.test)
|
assert.ok(proxy.test)
|
||||||
@ -64,21 +77,4 @@ describe('# Network Controller', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function dummyProviderConstructor() {
|
|
||||||
return {
|
|
||||||
// provider
|
|
||||||
sendAsync: noop,
|
|
||||||
// block tracker
|
|
||||||
_blockTracker: {},
|
|
||||||
start: noop,
|
|
||||||
stop: noop,
|
|
||||||
on: noop,
|
|
||||||
addListener: noop,
|
|
||||||
once: noop,
|
|
||||||
removeAllListeners: noop,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
133
test/unit/seed-phrase-verifier-test.js
Normal file
133
test/unit/seed-phrase-verifier-test.js
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
const assert = require('assert')
|
||||||
|
const clone = require('clone')
|
||||||
|
const KeyringController = require('eth-keyring-controller')
|
||||||
|
const firstTimeState = require('../../app/scripts/first-time-state')
|
||||||
|
const seedPhraseVerifier = require('../../app/scripts/lib/seed-phrase-verifier')
|
||||||
|
const mockEncryptor = require('../lib/mock-encryptor')
|
||||||
|
|
||||||
|
describe('SeedPhraseVerifier', function () {
|
||||||
|
|
||||||
|
describe('verifyAccounts', function () {
|
||||||
|
|
||||||
|
let password = 'passw0rd1'
|
||||||
|
let hdKeyTree = 'HD Key Tree'
|
||||||
|
|
||||||
|
let keyringController
|
||||||
|
let vault
|
||||||
|
let primaryKeyring
|
||||||
|
|
||||||
|
beforeEach(async function () {
|
||||||
|
keyringController = new KeyringController({
|
||||||
|
initState: clone(firstTimeState),
|
||||||
|
encryptor: mockEncryptor,
|
||||||
|
})
|
||||||
|
|
||||||
|
assert(keyringController)
|
||||||
|
|
||||||
|
vault = await keyringController.createNewVaultAndKeychain(password)
|
||||||
|
primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should be able to verify created account with seed words', async function () {
|
||||||
|
|
||||||
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
|
||||||
|
let serialized = await primaryKeyring.serialize()
|
||||||
|
let seedWords = serialized.mnemonic
|
||||||
|
assert.notEqual(seedWords.length, 0)
|
||||||
|
|
||||||
|
let result = await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should be able to verify created account (upper case) with seed words', async function () {
|
||||||
|
|
||||||
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
|
||||||
|
let upperCaseAccounts = [createdAccounts[0].toUpperCase()]
|
||||||
|
|
||||||
|
let serialized = await primaryKeyring.serialize()
|
||||||
|
let seedWords = serialized.mnemonic
|
||||||
|
assert.notEqual(seedWords.length, 0)
|
||||||
|
|
||||||
|
let result = await seedPhraseVerifier.verifyAccounts(upperCaseAccounts, seedWords)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should be able to verify created account (lower case) with seed words', async function () {
|
||||||
|
|
||||||
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
let lowerCaseAccounts = [createdAccounts[0].toLowerCase()]
|
||||||
|
|
||||||
|
let serialized = await primaryKeyring.serialize()
|
||||||
|
let seedWords = serialized.mnemonic
|
||||||
|
assert.notEqual(seedWords.length, 0)
|
||||||
|
|
||||||
|
let result = await seedPhraseVerifier.verifyAccounts(lowerCaseAccounts, seedWords)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return error with good but different seed words', async function () {
|
||||||
|
|
||||||
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
|
||||||
|
let serialized = await primaryKeyring.serialize()
|
||||||
|
let seedWords = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
|
||||||
|
|
||||||
|
try {
|
||||||
|
let result = await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
|
||||||
|
assert.fail("Should reject")
|
||||||
|
} catch (err) {
|
||||||
|
assert.ok(err.message.indexOf('Not identical accounts!') >= 0, 'Wrong error message')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return error with undefined existing accounts', async function () {
|
||||||
|
|
||||||
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
|
||||||
|
let serialized = await primaryKeyring.serialize()
|
||||||
|
let seedWords = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
|
||||||
|
|
||||||
|
try {
|
||||||
|
let result = await seedPhraseVerifier.verifyAccounts(undefined, seedWords)
|
||||||
|
assert.fail("Should reject")
|
||||||
|
} catch (err) {
|
||||||
|
assert.equal(err.message, 'No created accounts defined.')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return error with empty accounts array', async function () {
|
||||||
|
|
||||||
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
|
||||||
|
let serialized = await primaryKeyring.serialize()
|
||||||
|
let seedWords = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
|
||||||
|
|
||||||
|
try {
|
||||||
|
let result = await seedPhraseVerifier.verifyAccounts([], seedWords)
|
||||||
|
assert.fail("Should reject")
|
||||||
|
} catch (err) {
|
||||||
|
assert.equal(err.message, 'No created accounts defined.')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should be able to verify more than one created account with seed words', async function () {
|
||||||
|
|
||||||
|
const keyState = await keyringController.addNewAccount(primaryKeyring)
|
||||||
|
const keyState2 = await keyringController.addNewAccount(primaryKeyring)
|
||||||
|
|
||||||
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
|
assert.equal(createdAccounts.length, 3)
|
||||||
|
|
||||||
|
let serialized = await primaryKeyring.serialize()
|
||||||
|
let seedWords = serialized.mnemonic
|
||||||
|
assert.notEqual(seedWords.length, 0)
|
||||||
|
|
||||||
|
let result = await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -5,7 +5,7 @@ const TxStateManager = require('../../app/scripts/lib/tx-state-manager')
|
|||||||
const txStateHistoryHelper = require('../../app/scripts/lib/tx-state-history-helper')
|
const txStateHistoryHelper = require('../../app/scripts/lib/tx-state-history-helper')
|
||||||
const noop = () => true
|
const noop = () => true
|
||||||
|
|
||||||
describe('TransactionStateManger', function () {
|
describe('TransactionStateManager', function () {
|
||||||
let txStateManager
|
let txStateManager
|
||||||
const currentNetworkId = 42
|
const currentNetworkId = 42
|
||||||
const otherNetworkId = 2
|
const otherNetworkId = 2
|
||||||
@ -281,4 +281,4 @@ describe('TransactionStateManger', function () {
|
|||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -35,6 +35,21 @@ AccountImportSubview.prototype.render = function () {
|
|||||||
return (
|
return (
|
||||||
h('div.new-account-import-form', [
|
h('div.new-account-import-form', [
|
||||||
|
|
||||||
|
h('.new-account-import-disclaimer', [
|
||||||
|
h('span', 'Imported accounts will not be associated with your originally created MetaMask account seedphrase. Learn more about imported accounts '),
|
||||||
|
h('span', {
|
||||||
|
style: {
|
||||||
|
cursor: 'pointer',
|
||||||
|
textDecoration: 'underline',
|
||||||
|
},
|
||||||
|
onClick: () => {
|
||||||
|
global.platform.openWindow({
|
||||||
|
url: 'https://metamask.helpscoutdocs.com/article/17-what-are-loose-accounts',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}, 'here'),
|
||||||
|
]),
|
||||||
|
|
||||||
h('div.new-account-import-form__select-section', [
|
h('div.new-account-import-form__select-section', [
|
||||||
|
|
||||||
h('div.new-account-import-form__select-label', 'Select Type'),
|
h('div.new-account-import-form__select-label', 'Select Type'),
|
||||||
|
@ -284,20 +284,43 @@ function goHome () {
|
|||||||
// async actions
|
// async actions
|
||||||
|
|
||||||
function tryUnlockMetamask (password) {
|
function tryUnlockMetamask (password) {
|
||||||
return (dispatch) => {
|
return dispatch => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
dispatch(actions.unlockInProgress())
|
dispatch(actions.unlockInProgress())
|
||||||
log.debug(`background.submitPassword`)
|
log.debug(`background.submitPassword`)
|
||||||
background.submitPassword(password, (err) => {
|
|
||||||
dispatch(actions.hideLoadingIndication())
|
return new Promise((resolve, reject) => {
|
||||||
if (err) {
|
background.submitPassword(password, error => {
|
||||||
dispatch(actions.unlockFailed(err.message))
|
if (error) {
|
||||||
} else {
|
return reject(error)
|
||||||
dispatch(actions.unlockSucceeded())
|
}
|
||||||
dispatch(actions.transitionForward())
|
|
||||||
forceUpdateMetamaskState(dispatch)
|
resolve()
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
dispatch(actions.unlockSucceeded())
|
||||||
|
return forceUpdateMetamaskState(dispatch)
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
background.verifySeedPhrase(err => {
|
||||||
|
if (err) {
|
||||||
|
dispatch(actions.displayWarning(err.message))
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
dispatch(actions.transitionForward())
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
dispatch(actions.unlockFailed(err.message))
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,46 +362,53 @@ function createNewVaultAndRestore (password, seed) {
|
|||||||
log.debug(`background.createNewVaultAndRestore`)
|
log.debug(`background.createNewVaultAndRestore`)
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
background.createNewVaultAndRestore(password, seed, (err) => {
|
background.createNewVaultAndRestore(password, seed, err => {
|
||||||
|
|
||||||
dispatch(actions.hideLoadingIndication())
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(actions.displayWarning(err.message))
|
|
||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(actions.showAccountsPage())
|
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.then(() => dispatch(actions.unMarkPasswordForgotten()))
|
||||||
|
.then(() => {
|
||||||
|
dispatch(actions.showAccountsPage())
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
dispatch(actions.displayWarning(err.message))
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNewVaultAndKeychain (password) {
|
function createNewVaultAndKeychain (password) {
|
||||||
return (dispatch) => {
|
return dispatch => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
log.debug(`background.createNewVaultAndKeychain`)
|
log.debug(`background.createNewVaultAndKeychain`)
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
background.createNewVaultAndKeychain(password, (err) => {
|
background.createNewVaultAndKeychain(password, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(actions.displayWarning(err.message))
|
dispatch(actions.displayWarning(err.message))
|
||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug(`background.placeSeedWords`)
|
log.debug(`background.placeSeedWords`)
|
||||||
|
|
||||||
background.placeSeedWords((err) => {
|
background.placeSeedWords((err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(actions.displayWarning(err.message))
|
dispatch(actions.displayWarning(err.message))
|
||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
dispatch(actions.hideLoadingIndication())
|
|
||||||
forceUpdateMetamaskState(dispatch)
|
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.then(() => forceUpdateMetamaskState(dispatch))
|
||||||
|
.then(() => dispatch(actions.hideLoadingIndication()))
|
||||||
|
.catch(() => dispatch(actions.hideLoadingIndication()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,18 +419,27 @@ function revealSeedConfirmation () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function requestRevealSeed (password) {
|
function requestRevealSeed (password) {
|
||||||
return (dispatch) => {
|
return dispatch => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
log.debug(`background.submitPassword`)
|
log.debug(`background.submitPassword`)
|
||||||
background.submitPassword(password, (err) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (err) {
|
background.submitPassword(password, err => {
|
||||||
return dispatch(actions.displayWarning(err.message))
|
if (err) {
|
||||||
}
|
dispatch(actions.displayWarning(err.message))
|
||||||
log.debug(`background.placeSeedWords`)
|
return reject(err)
|
||||||
background.placeSeedWords((err, result) => {
|
}
|
||||||
if (err) return dispatch(actions.displayWarning(err.message))
|
|
||||||
dispatch(actions.hideLoadingIndication())
|
log.debug(`background.placeSeedWords`)
|
||||||
dispatch(actions.showNewVaultSeed(result))
|
background.placeSeedWords((err, result) => {
|
||||||
|
if (err) {
|
||||||
|
dispatch(actions.displayWarning(err.message))
|
||||||
|
return reject(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(actions.showNewVaultSeed(result))
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -851,11 +890,14 @@ function markPasswordForgotten () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function unMarkPasswordForgotten () {
|
function unMarkPasswordForgotten () {
|
||||||
return (dispatch) => {
|
return dispatch => {
|
||||||
return background.unMarkPasswordForgotten(() => {
|
return new Promise(resolve => {
|
||||||
dispatch(actions.forgotPassword(false))
|
background.unMarkPasswordForgotten(() => {
|
||||||
forceUpdateMetamaskState(dispatch)
|
dispatch(actions.forgotPassword(false))
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
.then(() => forceUpdateMetamaskState(dispatch))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1500,6 +1542,7 @@ function pairUpdate (coin) {
|
|||||||
dispatch(actions.hideWarning())
|
dispatch(actions.hideWarning())
|
||||||
shapeShiftRequest('marketinfo', {pair: `${coin.toLowerCase()}_eth`}, (mktResponse) => {
|
shapeShiftRequest('marketinfo', {pair: `${coin.toLowerCase()}_eth`}, (mktResponse) => {
|
||||||
dispatch(actions.hideSubLoadingIndication())
|
dispatch(actions.hideSubLoadingIndication())
|
||||||
|
if (mktResponse.error) return dispatch(actions.displayWarning(mktResponse.error))
|
||||||
dispatch({
|
dispatch({
|
||||||
type: actions.PAIR_UPDATE,
|
type: actions.PAIR_UPDATE,
|
||||||
value: {
|
value: {
|
||||||
@ -1705,11 +1748,16 @@ function callBackgroundThenUpdate (method, ...args) {
|
|||||||
|
|
||||||
function forceUpdateMetamaskState (dispatch) {
|
function forceUpdateMetamaskState (dispatch) {
|
||||||
log.debug(`background.getState`)
|
log.debug(`background.getState`)
|
||||||
background.getState((err, newState) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (err) {
|
background.getState((err, newState) => {
|
||||||
return dispatch(actions.displayWarning(err.message))
|
if (err) {
|
||||||
}
|
dispatch(actions.displayWarning(err.message))
|
||||||
dispatch(actions.updateMetamaskState(newState))
|
return reject(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(actions.updateMetamaskState(newState))
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,22 +134,6 @@ class AccountDropdowns extends Component {
|
|||||||
]),
|
]),
|
||||||
|
|
||||||
]),
|
]),
|
||||||
// =======
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// this.indicateIfLoose(keyring),
|
|
||||||
// h('span', {
|
|
||||||
// style: {
|
|
||||||
// marginLeft: '20px',
|
|
||||||
// fontSize: '24px',
|
|
||||||
// maxWidth: '145px',
|
|
||||||
// whiteSpace: 'nowrap',
|
|
||||||
// overflow: 'hidden',
|
|
||||||
// textOverflow: 'ellipsis',
|
|
||||||
// },
|
|
||||||
// }, identity.name || ''),
|
|
||||||
// h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, isSelected ? h('.check', '✓') : null),
|
|
||||||
// >>>>>>> master:ui/app/components/account-dropdowns.js
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -159,7 +143,7 @@ class AccountDropdowns extends Component {
|
|||||||
try { // Sometimes keyrings aren't loaded yet:
|
try { // Sometimes keyrings aren't loaded yet:
|
||||||
const type = keyring.type
|
const type = keyring.type
|
||||||
const isLoose = type !== 'HD Key Tree'
|
const isLoose = type !== 'HD Key Tree'
|
||||||
return isLoose ? h('.keyring-label', 'LOOSE') : null
|
return isLoose ? h('.keyring-label', 'IMPORTED') : null
|
||||||
} catch (e) { return }
|
} catch (e) { return }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ NetworkDropdown.prototype.render = function () {
|
|||||||
[
|
[
|
||||||
providerType === 'mainnet' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
|
providerType === 'mainnet' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
|
||||||
h(NetworkDropdownIcon, {
|
h(NetworkDropdownIcon, {
|
||||||
backgroundColor: '#038789', // $blue-lagoon
|
backgroundColor: '#29B6AF', // $java
|
||||||
isSelected: providerType === 'mainnet',
|
isSelected: providerType === 'mainnet',
|
||||||
}),
|
}),
|
||||||
h('span.network-name-item', {
|
h('span.network-name-item', {
|
||||||
@ -136,7 +136,7 @@ NetworkDropdown.prototype.render = function () {
|
|||||||
[
|
[
|
||||||
providerType === 'ropsten' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
|
providerType === 'ropsten' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
|
||||||
h(NetworkDropdownIcon, {
|
h(NetworkDropdownIcon, {
|
||||||
backgroundColor: '#e91550', // $crimson
|
backgroundColor: '#ff4a8d', // $wild-strawberry
|
||||||
isSelected: providerType === 'ropsten',
|
isSelected: providerType === 'ropsten',
|
||||||
}),
|
}),
|
||||||
h('span.network-name-item', {
|
h('span.network-name-item', {
|
||||||
@ -158,7 +158,7 @@ NetworkDropdown.prototype.render = function () {
|
|||||||
[
|
[
|
||||||
providerType === 'kovan' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
|
providerType === 'kovan' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
|
||||||
h(NetworkDropdownIcon, {
|
h(NetworkDropdownIcon, {
|
||||||
backgroundColor: '#690496', // $purple
|
backgroundColor: '#7057ff', // $cornflower-blue
|
||||||
isSelected: providerType === 'kovan',
|
isSelected: providerType === 'kovan',
|
||||||
}),
|
}),
|
||||||
h('span.network-name-item', {
|
h('span.network-name-item', {
|
||||||
@ -180,7 +180,7 @@ NetworkDropdown.prototype.render = function () {
|
|||||||
[
|
[
|
||||||
providerType === 'rinkeby' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
|
providerType === 'rinkeby' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
|
||||||
h(NetworkDropdownIcon, {
|
h(NetworkDropdownIcon, {
|
||||||
backgroundColor: '#ebb33f', // $tulip-tree
|
backgroundColor: '#f6c343', // $saffron
|
||||||
isSelected: providerType === 'rinkeby',
|
isSelected: providerType === 'rinkeby',
|
||||||
}),
|
}),
|
||||||
h('span.network-name-item', {
|
h('span.network-name-item', {
|
||||||
|
@ -33,6 +33,9 @@ function mapDispatchToProps (dispatch) {
|
|||||||
hideModal: () => {
|
hideModal: () => {
|
||||||
dispatch(actions.hideModal())
|
dispatch(actions.hideModal())
|
||||||
},
|
},
|
||||||
|
hideWarning: () => {
|
||||||
|
dispatch(actions.hideWarning())
|
||||||
|
},
|
||||||
showAccountDetailModal: () => {
|
showAccountDetailModal: () => {
|
||||||
dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' }))
|
dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' }))
|
||||||
},
|
},
|
||||||
@ -119,6 +122,7 @@ DepositEtherModal.prototype.render = function () {
|
|||||||
h('div.deposit-ether-modal__header__close', {
|
h('div.deposit-ether-modal__header__close', {
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
this.setState({ buyingWithShapeshift: false })
|
this.setState({ buyingWithShapeshift: false })
|
||||||
|
this.props.hideWarning()
|
||||||
this.props.hideModal()
|
this.props.hideModal()
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -179,6 +183,7 @@ DepositEtherModal.prototype.render = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DepositEtherModal.prototype.goToAccountDetailsModal = function () {
|
DepositEtherModal.prototype.goToAccountDetailsModal = function () {
|
||||||
|
this.props.hideWarning()
|
||||||
this.props.hideModal()
|
this.props.hideModal()
|
||||||
this.props.showAccountDetailModal()
|
this.props.showAccountDetailModal()
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ const MODALS = {
|
|||||||
contents: [
|
contents: [
|
||||||
h(DepositEtherModal, {}, []),
|
h(DepositEtherModal, {}, []),
|
||||||
],
|
],
|
||||||
|
onHide: (props) => props.hideWarning(),
|
||||||
mobileModalStyle: {
|
mobileModalStyle: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@ -286,6 +287,10 @@ function mapDispatchToProps (dispatch) {
|
|||||||
hideModal: () => {
|
hideModal: () => {
|
||||||
dispatch(actions.hideModal())
|
dispatch(actions.hideModal())
|
||||||
},
|
},
|
||||||
|
hideWarning: () => {
|
||||||
|
dispatch(actions.hideWarning())
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +313,12 @@ Modal.prototype.render = function () {
|
|||||||
{
|
{
|
||||||
className: 'modal',
|
className: 'modal',
|
||||||
keyboard: false,
|
keyboard: false,
|
||||||
onHide: () => { this.onHide() },
|
onHide: () => {
|
||||||
|
if (modal.onHide) {
|
||||||
|
modal.onHide(this.props)
|
||||||
|
}
|
||||||
|
this.onHide()
|
||||||
|
},
|
||||||
ref: (ref) => {
|
ref: (ref) => {
|
||||||
this.modalRef = ref
|
this.modalRef = ref
|
||||||
},
|
},
|
||||||
|
@ -14,11 +14,13 @@ function mapStateToProps (state) {
|
|||||||
tokenExchangeRates,
|
tokenExchangeRates,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
} = state.metamask
|
} = state.metamask
|
||||||
|
const { warning } = state.appState
|
||||||
|
|
||||||
return {
|
return {
|
||||||
coinOptions,
|
coinOptions,
|
||||||
tokenExchangeRates,
|
tokenExchangeRates,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
|
warning,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +165,7 @@ ShapeshiftForm.prototype.renderQrCode = function () {
|
|||||||
|
|
||||||
|
|
||||||
ShapeshiftForm.prototype.render = function () {
|
ShapeshiftForm.prototype.render = function () {
|
||||||
const { coinOptions, btnClass } = this.props
|
const { coinOptions, btnClass, warning } = this.props
|
||||||
const { depositCoin, errorMessage, showQrCode, depositAddress } = this.state
|
const { depositCoin, errorMessage, showQrCode, depositAddress } = this.state
|
||||||
const coinPair = `${depositCoin}_eth`
|
const coinPair = `${depositCoin}_eth`
|
||||||
const { tokenExchangeRates } = this.props
|
const { tokenExchangeRates } = this.props
|
||||||
@ -206,7 +208,9 @@ ShapeshiftForm.prototype.render = function () {
|
|||||||
|
|
||||||
]),
|
]),
|
||||||
|
|
||||||
h('div', {
|
warning && h('div.shapeshift-form__address-input-label', warning),
|
||||||
|
|
||||||
|
!warning && h('div', {
|
||||||
className: classnames('shapeshift-form__address-input-wrapper', {
|
className: classnames('shapeshift-form__address-input-wrapper', {
|
||||||
'shapeshift-form__address-input-wrapper--error': errorMessage,
|
'shapeshift-form__address-input-wrapper--error': errorMessage,
|
||||||
}),
|
}),
|
||||||
@ -227,7 +231,7 @@ ShapeshiftForm.prototype.render = function () {
|
|||||||
h('divshapeshift-form__address-input-error-message', [errorMessage]),
|
h('divshapeshift-form__address-input-error-message', [errorMessage]),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
this.renderMarketInfo(),
|
!warning && this.renderMarketInfo(),
|
||||||
|
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
@ -66,8 +66,9 @@
|
|||||||
|
|
||||||
.keyring-label {
|
.keyring-label {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
background-color: $black;
|
background-color: $dusty-gray;
|
||||||
color: $dusty-gray;
|
color: $black;
|
||||||
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,6 +787,10 @@
|
|||||||
width: auto;
|
width: auto;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 575px) {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,16 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-account-import-disclaimer {
|
||||||
|
width: 120%;
|
||||||
|
background-color: #F4F9FC;
|
||||||
|
display: inline-block;
|
||||||
|
align-items: center;
|
||||||
|
padding: 20px 30px 20px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
.new-account-import-form {
|
.new-account-import-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
|
@ -47,6 +47,10 @@ $spindle: #c7ddec;
|
|||||||
$mid-gray: #5b5d67;
|
$mid-gray: #5b5d67;
|
||||||
$cape-cod: #38393a;
|
$cape-cod: #38393a;
|
||||||
$onahau: #d1edff;
|
$onahau: #d1edff;
|
||||||
|
$java: #29b6af;
|
||||||
|
$wild-strawberry: #ff4a8d;
|
||||||
|
$cornflower-blue: #7057ff;
|
||||||
|
$saffron: #f6c343;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Z-Indicies
|
Z-Indicies
|
||||||
|
@ -107,12 +107,15 @@ RestoreVaultScreen.prototype.render = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RestoreVaultScreen.prototype.showInitializeMenu = function () {
|
RestoreVaultScreen.prototype.showInitializeMenu = function () {
|
||||||
this.props.dispatch(actions.unMarkPasswordForgotten())
|
const { dispatch, forgottenPassword } = this.props
|
||||||
if (this.props.forgottenPassword) {
|
dispatch(actions.unMarkPasswordForgotten())
|
||||||
this.props.dispatch(actions.backToUnlockView())
|
.then(() => {
|
||||||
} else {
|
if (forgottenPassword) {
|
||||||
this.props.dispatch(actions.showInitializeMenu())
|
dispatch(actions.backToUnlockView())
|
||||||
}
|
} else {
|
||||||
|
dispatch(actions.showInitializeMenu())
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
RestoreVaultScreen.prototype.createOnEnter = function (event) {
|
RestoreVaultScreen.prototype.createOnEnter = function (event) {
|
||||||
@ -150,11 +153,5 @@ RestoreVaultScreen.prototype.createNewVaultAndRestore = function () {
|
|||||||
this.warning = null
|
this.warning = null
|
||||||
this.props.dispatch(actions.displayWarning(this.warning))
|
this.props.dispatch(actions.displayWarning(this.warning))
|
||||||
this.props.dispatch(actions.createNewVaultAndRestore(password, seed))
|
this.props.dispatch(actions.createNewVaultAndRestore(password, seed))
|
||||||
.then(() => {
|
.catch(err => log.error(err.message))
|
||||||
this.props.dispatch(actions.unMarkPasswordForgotten())
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
log.error(err.message)
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -138,14 +138,18 @@ function reduceApp (state, action) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
case actions.FORGOT_PASSWORD:
|
case actions.FORGOT_PASSWORD:
|
||||||
return extend(appState, {
|
const newState = extend(appState, {
|
||||||
currentView: {
|
|
||||||
name: action.value ? 'restoreVault' : 'accountDetail',
|
|
||||||
},
|
|
||||||
transForward: false,
|
|
||||||
forgottenPassword: action.value,
|
forgottenPassword: action.value,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (action.value) {
|
||||||
|
newState.currentView = {
|
||||||
|
name: 'restoreVault',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return newState
|
||||||
|
|
||||||
case actions.SHOW_INIT_MENU:
|
case actions.SHOW_INIT_MENU:
|
||||||
return extend(appState, {
|
return extend(appState, {
|
||||||
currentView: defaultView,
|
currentView: defaultView,
|
||||||
|
@ -132,8 +132,6 @@ function reduceMetamask (state, action) {
|
|||||||
|
|
||||||
case actions.SHOW_NEW_VAULT_SEED:
|
case actions.SHOW_NEW_VAULT_SEED:
|
||||||
return extend(metamaskState, {
|
return extend(metamaskState, {
|
||||||
isUnlocked: true,
|
|
||||||
isInitialized: false,
|
|
||||||
isRevealingSeedWords: true,
|
isRevealingSeedWords: true,
|
||||||
seedWords: action.value,
|
seedWords: action.value,
|
||||||
})
|
})
|
||||||
|
@ -361,8 +361,9 @@ SendTransactionScreen.prototype.validateAmount = function (value) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const verifyTokenBalance = selectedToken && tokenBalance !== null
|
||||||
let sufficientTokens
|
let sufficientTokens
|
||||||
if (selectedToken) {
|
if (verifyTokenBalance) {
|
||||||
sufficientTokens = isTokenBalanceSufficient({
|
sufficientTokens = isTokenBalanceSufficient({
|
||||||
tokenBalance,
|
tokenBalance,
|
||||||
amount,
|
amount,
|
||||||
@ -377,7 +378,7 @@ SendTransactionScreen.prototype.validateAmount = function (value) {
|
|||||||
|
|
||||||
if (conversionRate && !sufficientBalance) {
|
if (conversionRate && !sufficientBalance) {
|
||||||
amountError = 'Insufficient funds.'
|
amountError = 'Insufficient funds.'
|
||||||
} else if (selectedToken && !sufficientTokens) {
|
} else if (verifyTokenBalance && !sufficientTokens) {
|
||||||
amountError = 'Insufficient tokens.'
|
amountError = 'Insufficient tokens.'
|
||||||
} else if (amountLessThanZero) {
|
} else if (amountLessThanZero) {
|
||||||
amountError = 'Can not send negative amounts of ETH.'
|
amountError = 'Can not send negative amounts of ETH.'
|
||||||
@ -396,14 +397,15 @@ SendTransactionScreen.prototype.renderAmountRow = function () {
|
|||||||
amount,
|
amount,
|
||||||
setMaxModeTo,
|
setMaxModeTo,
|
||||||
maxModeOn,
|
maxModeOn,
|
||||||
|
gasTotal,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
return h('div.send-v2__form-row', [
|
return h('div.send-v2__form-row', [
|
||||||
|
|
||||||
h('div.send-v2__form-label', [
|
h('div.send-v2__form-label', [
|
||||||
'Amount:',
|
'Amount:',
|
||||||
this.renderErrorMessage('amount'),
|
this.renderErrorMessage('amount'),
|
||||||
!errors.amount && h('div.send-v2__amount-max', {
|
!errors.amount && gasTotal && h('div.send-v2__amount-max', {
|
||||||
onClick: (event) => {
|
onClick: (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
setMaxModeTo(true)
|
setMaxModeTo(true)
|
||||||
@ -491,9 +493,12 @@ SendTransactionScreen.prototype.renderFooter = function () {
|
|||||||
goHome,
|
goHome,
|
||||||
clearSend,
|
clearSend,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
|
tokenBalance,
|
||||||
|
selectedToken,
|
||||||
errors: { amount: amountError, to: toError },
|
errors: { amount: amountError, to: toError },
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
|
const missingTokenBalance = selectedToken && !tokenBalance
|
||||||
const noErrors = !amountError && toError === null
|
const noErrors = !amountError && toError === null
|
||||||
|
|
||||||
return h('div.page-container__footer', [
|
return h('div.page-container__footer', [
|
||||||
@ -504,7 +509,7 @@ SendTransactionScreen.prototype.renderFooter = function () {
|
|||||||
},
|
},
|
||||||
}, 'Cancel'),
|
}, 'Cancel'),
|
||||||
h('button.btn-clear.page-container__footer-button', {
|
h('button.btn-clear.page-container__footer-button', {
|
||||||
disabled: !noErrors || !gasTotal,
|
disabled: !noErrors || !gasTotal || missingTokenBalance,
|
||||||
onClick: event => this.onSubmit(event),
|
onClick: event => this.onSubmit(event),
|
||||||
}, 'Next'),
|
}, 'Next'),
|
||||||
])
|
])
|
||||||
|
@ -71,7 +71,7 @@ UnlockScreen.prototype.render = function () {
|
|||||||
style: {
|
style: {
|
||||||
margin: 10,
|
margin: 10,
|
||||||
},
|
},
|
||||||
}, 'Unlock'),
|
}, 'Log In'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
h('.flex-row.flex-center.flex-grow', [
|
h('.flex-row.flex-center.flex-grow', [
|
||||||
@ -104,7 +104,7 @@ UnlockScreen.prototype.render = function () {
|
|||||||
},
|
},
|
||||||
}, 'Use classic interface'),
|
}, 'Use classic interface'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
74
yarn.lock
74
yarn.lock
@ -221,12 +221,6 @@ ansi-colors@^1.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ansi-wrap "^0.1.0"
|
ansi-wrap "^0.1.0"
|
||||||
|
|
||||||
ansi-cyan@^0.1.1:
|
|
||||||
version "0.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/ansi-cyan/-/ansi-cyan-0.1.1.tgz#538ae528af8982f28ae30d86f2f17456d2609873"
|
|
||||||
dependencies:
|
|
||||||
ansi-wrap "0.1.0"
|
|
||||||
|
|
||||||
ansi-escapes@^3.0.0:
|
ansi-escapes@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92"
|
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92"
|
||||||
@ -237,12 +231,6 @@ ansi-gray@^0.1.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ansi-wrap "0.1.0"
|
ansi-wrap "0.1.0"
|
||||||
|
|
||||||
ansi-red@^0.1.1:
|
|
||||||
version "0.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/ansi-red/-/ansi-red-0.1.1.tgz#8c638f9d1080800a353c9c28c8a81ca4705d946c"
|
|
||||||
dependencies:
|
|
||||||
ansi-wrap "0.1.0"
|
|
||||||
|
|
||||||
ansi-regex@^0.2.0, ansi-regex@^0.2.1:
|
ansi-regex@^0.2.0, ansi-regex@^0.2.1:
|
||||||
version "0.2.1"
|
version "0.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9"
|
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9"
|
||||||
@ -332,13 +320,6 @@ argparse@^1.0.7:
|
|||||||
dependencies:
|
dependencies:
|
||||||
sprintf-js "~1.0.2"
|
sprintf-js "~1.0.2"
|
||||||
|
|
||||||
arr-diff@^1.0.1:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-1.1.0.tgz#687c32758163588fef7de7b36fabe495eb1a399a"
|
|
||||||
dependencies:
|
|
||||||
arr-flatten "^1.0.1"
|
|
||||||
array-slice "^0.2.3"
|
|
||||||
|
|
||||||
arr-diff@^2.0.0:
|
arr-diff@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
|
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
|
||||||
@ -365,10 +346,6 @@ arr-map@^2.0.0, arr-map@^2.0.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
make-iterator "^1.0.0"
|
make-iterator "^1.0.0"
|
||||||
|
|
||||||
arr-union@^2.0.1:
|
|
||||||
version "2.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-2.1.0.tgz#20f9eab5ec70f5c7d215b1077b1c39161d292c7d"
|
|
||||||
|
|
||||||
arr-union@^3.1.0:
|
arr-union@^3.1.0:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4"
|
resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4"
|
||||||
@ -475,6 +452,10 @@ asap@~2.0.3:
|
|||||||
version "2.0.6"
|
version "2.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
||||||
|
|
||||||
|
asmcrypto.js@0.22.0:
|
||||||
|
version "0.22.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/asmcrypto.js/-/asmcrypto.js-0.22.0.tgz#38fc1440884d802c7bd37d1d23c2b26a5cd5d2d2"
|
||||||
|
|
||||||
asn1.js@^4.0.0:
|
asn1.js@^4.0.0:
|
||||||
version "4.9.2"
|
version "4.9.2"
|
||||||
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.2.tgz#8117ef4f7ed87cd8f89044b5bff97ac243a16c9a"
|
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.2.tgz#8117ef4f7ed87cd8f89044b5bff97ac243a16c9a"
|
||||||
@ -2432,6 +2413,10 @@ commander@~2.13.0:
|
|||||||
version "2.13.0"
|
version "2.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
|
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
|
||||||
|
|
||||||
|
commander@~2.14.1:
|
||||||
|
version "2.14.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa"
|
||||||
|
|
||||||
commondir@0.0.1:
|
commondir@0.0.1:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/commondir/-/commondir-0.0.1.tgz#89f00fdcd51b519c578733fec563e6a6da7f5be2"
|
resolved "https://registry.yarnpkg.com/commondir/-/commondir-0.0.1.tgz#89f00fdcd51b519c578733fec563e6a6da7f5be2"
|
||||||
@ -4380,12 +4365,6 @@ express@^4.10.7, express@^4.15.5:
|
|||||||
utils-merge "1.0.1"
|
utils-merge "1.0.1"
|
||||||
vary "~1.1.2"
|
vary "~1.1.2"
|
||||||
|
|
||||||
extend-shallow@^1.1.2:
|
|
||||||
version "1.1.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-1.1.4.tgz#19d6bf94dfc09d76ba711f39b872d21ff4dd9071"
|
|
||||||
dependencies:
|
|
||||||
kind-of "^1.1.0"
|
|
||||||
|
|
||||||
extend-shallow@^2.0.1:
|
extend-shallow@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
|
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
|
||||||
@ -5307,13 +5286,13 @@ gulp-stylelint@^4.0.0:
|
|||||||
stylelint "^8.0.0"
|
stylelint "^8.0.0"
|
||||||
through2 "^2.0.3"
|
through2 "^2.0.3"
|
||||||
|
|
||||||
gulp-uglify-es@^1.0.0:
|
gulp-uglify-es@^1.0.1:
|
||||||
version "1.0.0"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/gulp-uglify-es/-/gulp-uglify-es-1.0.0.tgz#80b2f8e2fa7211c1706c597f08bbf620c870e545"
|
resolved "https://registry.yarnpkg.com/gulp-uglify-es/-/gulp-uglify-es-1.0.1.tgz#9f991de31c646fb37fe589086ffd3f6e2f9e20f1"
|
||||||
dependencies:
|
dependencies:
|
||||||
o-stream "^0.2.2"
|
o-stream "^0.2.2"
|
||||||
plugin-error "^0.1.2"
|
plugin-error "^1.0.1"
|
||||||
uglify-es "^3.2.0"
|
uglify-es "^3.3.9"
|
||||||
vinyl "^2.1.0"
|
vinyl "^2.1.0"
|
||||||
vinyl-sourcemaps-apply "^0.2.1"
|
vinyl-sourcemaps-apply "^0.2.1"
|
||||||
|
|
||||||
@ -6650,10 +6629,6 @@ keccakjs@^0.2.0:
|
|||||||
browserify-sha3 "^0.0.1"
|
browserify-sha3 "^0.0.1"
|
||||||
sha3 "^1.1.0"
|
sha3 "^1.1.0"
|
||||||
|
|
||||||
kind-of@^1.1.0:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-1.1.0.tgz#140a3d2d41a36d2efcfa9377b62c24f8495a5c44"
|
|
||||||
|
|
||||||
kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.1.0, kind-of@^3.2.0:
|
kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.1.0, kind-of@^3.2.0:
|
||||||
version "3.2.2"
|
version "3.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
|
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
|
||||||
@ -8522,15 +8497,14 @@ plucker@0.0.0:
|
|||||||
version "0.0.0"
|
version "0.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/plucker/-/plucker-0.0.0.tgz#2ffa24e03ab2cffa4e75adc1df70f25623c45d09"
|
resolved "https://registry.yarnpkg.com/plucker/-/plucker-0.0.0.tgz#2ffa24e03ab2cffa4e75adc1df70f25623c45d09"
|
||||||
|
|
||||||
plugin-error@^0.1.2:
|
plugin-error@^1.0.1:
|
||||||
version "0.1.2"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-0.1.2.tgz#3b9bb3335ccf00f425e07437e19276967da47ace"
|
resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c"
|
||||||
dependencies:
|
dependencies:
|
||||||
ansi-cyan "^0.1.1"
|
ansi-colors "^1.0.1"
|
||||||
ansi-red "^0.1.1"
|
arr-diff "^4.0.0"
|
||||||
arr-diff "^1.0.1"
|
arr-union "^3.1.0"
|
||||||
arr-union "^2.0.1"
|
extend-shallow "^3.0.2"
|
||||||
extend-shallow "^1.1.2"
|
|
||||||
|
|
||||||
plur@^2.0.0, plur@^2.1.0, plur@^2.1.2:
|
plur@^2.0.0, plur@^2.1.0, plur@^2.1.2:
|
||||||
version "2.1.2"
|
version "2.1.2"
|
||||||
@ -11145,11 +11119,11 @@ uglify-es@^3.0.15:
|
|||||||
commander "~2.12.1"
|
commander "~2.12.1"
|
||||||
source-map "~0.6.1"
|
source-map "~0.6.1"
|
||||||
|
|
||||||
uglify-es@^3.2.0:
|
uglify-es@^3.3.9:
|
||||||
version "3.3.7"
|
version "3.3.10"
|
||||||
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.7.tgz#d1249af668666aba7cb1163e277455be9eb393cf"
|
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.10.tgz#8b0b7992cebe20edc26de1bf325cef797b8f3fa5"
|
||||||
dependencies:
|
dependencies:
|
||||||
commander "~2.13.0"
|
commander "~2.14.1"
|
||||||
source-map "~0.6.1"
|
source-map "~0.6.1"
|
||||||
|
|
||||||
uglify-js@^2.6, uglify-js@^2.8.27:
|
uglify-js@^2.6, uglify-js@^2.8.27:
|
||||||
|
Loading…
Reference in New Issue
Block a user