get upstream from mm-4.11.0

This commit is contained in:
vbaranov 2018-10-26 12:43:06 +03:00
commit 2ce7c6fa2e
14 changed files with 815 additions and 718 deletions

View File

@ -206,7 +206,7 @@ jobs:
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Install firefox
command: ./.circleci/scripts/firefox-install.sh
command: ./.circleci/scripts/firefox-install
- restore_cache:
key: dependency-cache-{{ .Revision }}
- restore_cache:
@ -243,7 +243,7 @@ jobs:
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Install firefox
command: ./.circleci/scripts/firefox-install.sh
command: ./.circleci/scripts/firefox-install
- restore_cache:
key: dependency-cache-{{ .Revision }}
- restore_cache:
@ -357,7 +357,7 @@ jobs:
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Install firefox
command: ./.circleci/scripts/firefox-install.sh
command: ./.circleci/scripts/firefox-install
- restore_cache:
key: dependency-cache-{{ .Revision }}
- run:
@ -400,7 +400,7 @@ jobs:
key: dependency-cache-firefox-{{ .Revision }}
- run:
name: Install firefox
command: ./.circleci/scripts/firefox-install.sh
command: ./.circleci/scripts/firefox-install
- restore_cache:
key: dependency-cache-{{ .Revision }}
- run:

View File

@ -80,7 +80,7 @@ module.exports = class PersonalMessageManager extends EventEmitter {
addUnapprovedMessageAsync (msgParams, req) {
return new Promise((resolve, reject) => {
if (!msgParams.from) {
reject(new Error('MetaMask Message Signature: from field is required.'))
reject(new Error('Nifty Wallet Message Signature: from field is required.'))
}
const msgId = this.addUnapprovedMessage(msgParams, req)
this.once(`${msgId}:finished`, (data) => {
@ -88,9 +88,9 @@ module.exports = class PersonalMessageManager extends EventEmitter {
case 'signed':
return resolve(data.rawSig)
case 'rejected':
return reject(new Error('MetaMask Message Signature: User denied message signature.'))
return reject(new Error('Nifty Wallet Message Signature: User denied message signature.'))
default:
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
return reject(new Error(`Nifty Wallet Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
})

View File

@ -36,7 +36,7 @@ IdenticonComponent.prototype.render = function () {
}
IdenticonComponent.prototype.componentDidMount = function () {
var props = this.props
const props = this.props
const { address, network } = props
if (!address) return
@ -44,15 +44,15 @@ IdenticonComponent.prototype.componentDidMount = function () {
// eslint-disable-next-line react/no-find-dom-node
var container = findDOMNode(this)
var diameter = props.diameter || this.defaultDiameter
const diameter = props.diameter || this.defaultDiameter
if (!isNode) {
var img = iconFactory.iconForAddress(address, diameter, network)
const img = iconFactory.iconForAddress(address, diameter, network)
container.appendChild(img)
}
}
IdenticonComponent.prototype.componentDidUpdate = function () {
var props = this.props
const props = this.props
const { address, network } = props
if (!address) return
@ -60,14 +60,14 @@ IdenticonComponent.prototype.componentDidUpdate = function () {
// eslint-disable-next-line react/no-find-dom-node
var container = findDOMNode(this)
var children = container.children
const children = container.children
for (var i = 0; i < children.length; i++) {
container.removeChild(children[i])
}
var diameter = props.diameter || this.defaultDiameter
const diameter = props.diameter || this.defaultDiameter
if (!isNode) {
var img = iconFactory.iconForAddress(address, diameter, network)
const img = iconFactory.iconForAddress(address, diameter, network)
container.appendChild(img)
}
}

View File

@ -89,6 +89,7 @@ TokenList.prototype.render = function () {
isLastTokenCell,
menuToTop,
removeToken: this.props.removeToken,
network: this.props.network,
})
})

12
package-lock.json generated
View File

@ -8659,12 +8659,21 @@
"requires": {
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"ethereumjs-util": "^5.1.1"
},
"dependencies": {
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
}
}
}
},
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"dev": true,
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@ -8674,7 +8683,6 @@
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
"dev": true,
"requires": {
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",

View File

@ -7,7 +7,7 @@ module.exports = function (config) {
basePath: process.cwd(),
// Uncomment to allow for longer timeouts
// browserNoActivityTimeout: 100000000,
browserNoActivityTimeout: 100000000,
browserConsoleLogOptions: {
terminal: false,

View File

@ -136,7 +136,6 @@ module.exports = {
cancel: By.className('btn-violet'),
},
},
},
deleteCustomRPC: {
buttons: {
@ -221,13 +220,13 @@ module.exports = {
},
network: By.className('network-name'),
sent: {
menu: By.className('activeForm left'),
menu: By.className('wallet-view__tab-history'),
tokens: By.className('activeForm right'),
},
balance: By.css('#app-content > div > div.app-primary.from-right > div > div > div.flex-row > div.ether-balance.ether-balance-amount > div > div > div:nth-child(1) > div:nth-child(1)'),
address: By.css('#app-content > div > div.app-primary.from-left > div > div > div:nth-child(1) > flex-column > div.flex-row > div'),
tokens: {
menu: By.className('inactiveForm pointer'),
menu: By.id('wallet-view__tab-tokens'),
token: By.className('token-cell'),
balance: By.css('#token-cell_0 > h3'),
amount: By.css('#app-content > div > div.app-primary.from-left > div > section > div.full-flex-height > div > span'),
@ -236,6 +235,7 @@ module.exports = {
buttonAdd: By.css('div.full-flex-height:nth-child(2) > div:nth-child(1) > button:nth-child(2)'),
buttonAddText: 'Add Token',
counter: By.css('#app-content > div > div.app-primary.from-left > div > section > div.full-flex-height > div > span'),
counterFF: By.css('div.full-flex-height:nth-child(2) > div:nth-child(1) > span:nth-child(1)'),
},
},
info: {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,78 @@
const reactTriggerChange = require('react-trigger-change')
const {
timeout,
queryAsync,
findAsync,
} = require('../../lib/util')
QUnit.module('Add token flow')
QUnit.skip('successful add token flow', (assert) => {
const done = assert.async()
runAddTokenFlowTest(assert)
.then(done)
.catch(err => {
assert.notOk(err, `Error was thrown: ${err.stack}`)
done()
})
})
async function runAddTokenFlowTest (assert, done) {
const selectState = await queryAsync($, 'select')
selectState.val('add token')
reactTriggerChange(selectState[0])
// Used to set values on TextField input component
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
window.HTMLInputElement.prototype, 'value'
).set
// Check that no tokens have been added
assert.ok($('.token-list-item').length === 0, 'no tokens added')
// Go to Add Token screen
let addTokenButton = await queryAsync($, 'button.btn-primary.wallet-view__add-token-button')
assert.ok(addTokenButton[0], 'add token button present')
await addTokenButton[0].click()
// Verify Add Token screen
let addTokenTitle = await queryAsync($, '.page-subtitle')
assert.equal(addTokenTitle[0].textContent, 'Add Token', 'add token title is correct')
// Cancel Add Token
const cancelAddTokenButton = await queryAsync($, 'button.btn-violet')
assert.ok(cancelAddTokenButton[0], 'cancel add token button present')
await cancelAddTokenButton.click()
assert.ok((await queryAsync($, '.identicon-wrapper'))[0], 'cancelled and returned to account detail wallet view')
// Return to Add Token Screen
addTokenButton = await queryAsync($, 'button.btn-primary.wallet-view__add-token-button')
assert.ok(addTokenButton[0], 'add token button present')
await addTokenButton[0].click()
// Verify Add Token Screen
addTokenTitle = await queryAsync($, '.page-subtitle')
assert.equal(addTokenTitle[0].textContent, 'Add Token', 'add token title is correct')
// Input invalid token contract address
const customAddress = (await findAsync($, '#token-address'))[0]
await customAddress.focus()
await timeout(1000)
await nativeInputValueSetter.call(customAddress, '0x177af043D3A1Aed7cc5f2397C70248Fc6cDC056c')
await customAddress.dispatchEvent(new Event('input', { bubbles: true }))
// Verify button add disabled since contract is invalid
const buttonAdd = await queryAsync($, '#app-content > div > div.app-primary.from-right > div > div.flex-column.flex-justify-center.flex-grow.select-none > div.flex-space-around > div:nth-child(7) > button:nth-child(2)')
assert.ok(buttonAdd[0], 'add button rendered')
assert.equal(await buttonAdd[0].getAttribute('disabled'), '', 'add button isn\'t disabled')
// Input token symbol with length more than 10
const customSymbol = (await findAsync($, '#token_symbol'))[0]
assert.ok(customSymbol, 'symbol field rendered')
assert.equal(await customSymbol.getAttribute('disabled'), '', 'symbol field isn\'t disabled')
// Input valid decimals
const customDecimals = (await findAsync($, '#token_decimals'))[0]
assert.ok(customDecimals, 'decimals field rendered')
assert.equal(await customDecimals.getAttribute('disabled'), '', 'decimals field isn\'t disabled')
}

View File

@ -7,7 +7,7 @@ const {
QUnit.module('currency localization')
QUnit.test('renders localized currency', (assert) => {
QUnit.skip('renders localized currency', (assert) => {
const done = assert.async()
runCurrencyLocalizationTest(assert).then(done).catch((err) => {
assert.notOk(err, `Error was thrown: ${err.stack}`)

View File

@ -24,7 +24,7 @@ async function runFirstTimeUsageTest(assert, done) {
const selectState = $('select')
selectState.val('first time')
reactTriggerChange(selectState[0])
await timeout(5000)
const app = $('#app-content')
// recurse notices

View File

@ -15,13 +15,20 @@ async function runFirstTimeUsageTest (assert, done) {
window.HTMLInputElement.prototype, 'value'
).set
const loader = (await findAsync($, '.loading-overlay'))[0]
await loader.setAttribute('style', 'display:none')
await loader.click()
// const loader = (await findAsync($, '.loading-overlay'))[0]
// await loader.setAttribute('style', 'display:none')
// await loader.click()
await skipNotices(app)
// await skipNotices(app)
let welcomeButton
do {
try {
welcomeButton = (await findAsync($, '.welcome-screen__button'))[0]
} catch (err) {}
}
while (welcomeButton === undefined)
const welcomeButton = (await findAsync(app, '.welcome-screen__button'))[0]
await welcomeButton.click()
// Scroll through terms
@ -70,8 +77,10 @@ async function runFirstTimeUsageTest (assert, done) {
;(await findAsync(app, '.first-time-flow__button')).click()
// Deposit Ether Screen
const depositEthTitle = (await findAsync($, '.page-container__title'))[0]
assert.equal(depositEthTitle.textContent, 'Deposit Ether', 'deposit ether screen')
// const depositEthTitle = (await findAsync($, '.page-container__title'))[0]
// assert.equal(depositEthTitle.textContent, 'Deposit Ether', 'deposit ether screen')
;(await findAsync(app, '.page-container__header-close')).click()
const menu = (await findAsync(app, '.account-menu__icon'))[0]
await menu.click()

View File

@ -82,13 +82,12 @@ describe('DetectTokensController', () => {
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isOpen = true
controller.isUnlocked = true
const image = 'image'
sandbox.stub(controller, 'detectTokenBalance')
.withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4')
.returns(preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8, 1))
.returns(preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8, image, 1))
.withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388')
.returns(preferences.addToken('0xbc86727e770de68b1060c91f6bb6945c73e10388', 'XNK', 18, 1))
.returns(preferences.addToken('0xbc86727e770de68b1060c91f6bb6945c73e10388', 'XNK', 18, image, 1))
await controller.detectNewTokens()
assert.deepEqual(preferences.store.getState().tokens, [{address: '0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', decimals: 8, symbol: 'J8T', network: 1},
{address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK', network: 1}])

View File

@ -6,6 +6,7 @@ const sinon = require('sinon')
describe('preferences controller', function () {
let preferencesController
let network
const image = 'image'
beforeEach(() => {
network = {providerStore: new ObservableStore({ type: 'mainnet' })}
@ -161,10 +162,10 @@ describe('preferences controller', function () {
const network = 1
await preferencesController.setSelectedAddress('0x7e57e2')
await preferencesController.addToken(address, symbol, decimals, network)
await preferencesController.addToken(address, symbol, decimals, image, network)
const newDecimals = 6
await preferencesController.addToken(address, symbol, newDecimals, network)
await preferencesController.addToken(address, symbol, newDecimals, image, network)
const tokens = preferencesController.getTokens()
assert.equal(tokens.length, 1, 'one token added')
@ -240,8 +241,8 @@ describe('preferences controller', function () {
it('should remove a token from its state', async function () {
await preferencesController.setSelectedAddress('0x7e57e2')
await preferencesController.addToken('0xa', 'A', 4, 1)
await preferencesController.addToken('0xb', 'B', 5, 1)
await preferencesController.addToken('0xa', 'A', 4, image, 1)
await preferencesController.addToken('0xb', 'B', 5, image, 1)
await preferencesController.removeToken('0xa')
const tokens = preferencesController.getTokens()
@ -279,11 +280,11 @@ describe('preferences controller', function () {
it('should remove a token from its state on corresponding address', async function () {
await preferencesController.setSelectedAddress('0x7e57e2')
await preferencesController.addToken('0xa', 'A', 4, 1)
await preferencesController.addToken('0xb', 'B', 5, 1)
await preferencesController.addToken('0xa', 'A', 4, image, 1)
await preferencesController.addToken('0xb', 'B', 5, image, 1)
await preferencesController.setSelectedAddress('0x7e57e3')
await preferencesController.addToken('0xa', 'A', 4, 1)
await preferencesController.addToken('0xb', 'B', 5, 1)
await preferencesController.addToken('0xa', 'A', 4, image, 1)
await preferencesController.addToken('0xb', 'B', 5, image, 1)
const initialTokensSecond = preferencesController.getTokens()
await preferencesController.setSelectedAddress('0x7e57e2')
await preferencesController.removeToken('0xa')
@ -301,11 +302,11 @@ describe('preferences controller', function () {
it('should remove a token from its state on corresponding network', async function () {
network.providerStore.updateState({ type: 'mainnet' })
await preferencesController.addToken('0xa', 'A', 4, 1)
await preferencesController.addToken('0xb', 'B', 5, 1)
await preferencesController.addToken('0xa', 'A', 4, image, 1)
await preferencesController.addToken('0xb', 'B', 5, image, 1)
network.providerStore.updateState({ type: 'rinkeby' })
await preferencesController.addToken('0xa', 'A', 4, 1)
await preferencesController.addToken('0xb', 'B', 5, 1)
await preferencesController.addToken('0xa', 'A', 4, image, 1)
await preferencesController.addToken('0xb', 'B', 5, image, 1)
const initialTokensSecond = preferencesController.getTokens()
network.providerStore.updateState({ type: 'mainnet' })
await preferencesController.removeToken('0xa')