Merge pull request #242 from dennis00010011b/e2e-owners-first

e2e contract-executor-reorder
This commit is contained in:
Victor Baranov 2018-12-27 13:02:34 +03:00 committed by GitHub
commit 606a519202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 396 additions and 210 deletions

View File

@ -169,7 +169,9 @@ class BuyButtonSubview extends Component {
backButtonContext () {
if (this.props.context === 'confTx') {
this.props.dispatch(actions.showConfTxPage(false))
this.props.dispatch(actions.showConfTxPage({
isContractExecutionByUser: this.props.isContractExecutionByUser,
}))
} else {
this.props.dispatch(actions.goHome())
}
@ -191,6 +193,7 @@ BuyButtonSubview.propTypes = {
buyView: PropTypes.object,
context: PropTypes.string,
provider: PropTypes.object,
isContractExecutionByUser: PropTypes.bool,
}
function mapStateToProps (state) {
@ -203,6 +206,7 @@ function mapStateToProps (state) {
provider: state.metamask.provider,
context: state.appState.currentView.context,
isSubLoading: state.appState.isSubLoading,
isContractExecutionByUser: state.appState.buyView.isContractExecutionByUser,
}
}

View File

@ -204,6 +204,7 @@ class ChooseContractExecutor extends Component {
const { selectedExecutor } = this.state
this.props.setSelectedAddress(selectedExecutor)
txParams.from = selectedExecutor
txParams.isContractExecutionByUser = true
this.props.signTx(txParams)
}

View File

@ -6,6 +6,7 @@ const actions = require('../../ui/app/actions')
const LoadingIndicator = require('./components/loading')
const txHelper = require('../lib/tx-helper')
const log = require('loglevel')
const { getCurrentKeyring, ifContractAcc } = require('./util')
const PendingTx = require('./components/pending-tx')
import PendingMsg from './components/pending-msg'
@ -20,6 +21,7 @@ function mapStateToProps (state) {
const { screenParams, pendingTxIndex } = appState.currentView
return {
identities: metamask.identities,
keyrings: metamask.keyrings,
accounts: metamask.accounts,
selectedAddress: metamask.selectedAddress,
unapprovedTxs: metamask.unapprovedTxs,
@ -38,6 +40,7 @@ function mapStateToProps (state) {
tokenSymbol: (screenParams && screenParams.tokenSymbol),
tokensToSend: (screenParams && screenParams.tokensToSend),
tokensTransferTo: (screenParams && screenParams.tokensTransferTo),
isContractExecutionByUser: (screenParams && screenParams.isContractExecutionByUser),
}
}
@ -109,7 +112,7 @@ ConfirmTxScreen.prototype.render = function () {
tokensToSend: props.tokensToSend,
tokensTransferTo: props.tokensTransferTo,
// Actions
buyEth: this.buyEth.bind(this, txParams.from || props.selectedAddress),
buyEth: this.buyEth.bind(this, txParams.from || props.selectedAddress, props.isContractExecutionByUser),
sendTransaction: this.sendTransaction.bind(this),
cancelTransaction: this.cancelTransaction.bind(this, txData),
cancelAllTransactions: this.cancelAllTransactions.bind(this, unconfTxList),
@ -148,26 +151,29 @@ function currentTxView (opts) {
}
}
ConfirmTxScreen.prototype.buyEth = function (address, event) {
ConfirmTxScreen.prototype.buyEth = function (address, isContractExecutionByUser, event) {
event.preventDefault()
this.props.dispatch(actions.buyEthView(address))
this.props.dispatch(actions.buyEthView(address, isContractExecutionByUser))
}
ConfirmTxScreen.prototype.sendTransaction = function (txData, event) {
this.stopPropagation(event)
this.props.dispatch(actions.updateAndApproveTx(txData))
this._checkIfContractExecutionAndUnlockContract(txData)
}
ConfirmTxScreen.prototype.cancelTransaction = function (txData, event) {
this.stopPropagation(event)
event.preventDefault()
this.props.dispatch(actions.cancelTx(txData))
this._checkIfContractExecutionAndUnlockContract(txData)
}
ConfirmTxScreen.prototype.cancelAllTransactions = function (unconfTxList, event) {
this.stopPropagation(event)
event.preventDefault()
this.props.dispatch(actions.cancelAllTx(unconfTxList))
this._checkIfMultipleContractExecutionAndUnlockContract(unconfTxList)
}
ConfirmTxScreen.prototype.signMessage = function (msgData, event) {
@ -218,6 +224,46 @@ ConfirmTxScreen.prototype.cancelTypedMessage = function (msgData, event) {
this.props.dispatch(actions.cancelTypedMsg(msgData))
}
ConfirmTxScreen.prototype._checkIfMultipleContractExecutionAndUnlockContract = function (unconfTxList) {
const areTxsToOneContractFromTheList = unconfTxList.slice(0).reduce((res, txData, ind, unconfTxList) => {
if (txData.txParams.data && this.props.isContractExecutionByUser) {
const to = txData && txData.txParams && txData.txParams.to
const targetContractIsInTheList = Object.keys(this.props.accounts).some((acc) => acc === to)
if (targetContractIsInTheList && Object.keys(res).length === 0) {
res = { status: true, to }
} else if (res.status && res.to !== to) {
res = { status: false }
unconfTxList.splice(1)
}
} else {
res = { status: false }
unconfTxList.splice(1)
}
return res
}, {})
if (areTxsToOneContractFromTheList.status) {
this._unlockContract(areTxsToOneContractFromTheList.to)
}
}
ConfirmTxScreen.prototype._checkIfContractExecutionAndUnlockContract = function (txData) {
if (txData.txParams.data && this.props.isContractExecutionByUser) {
const to = txData && txData.txParams && txData.txParams.to
const targetContractIsInTheList = Object.keys(this.props.accounts).some((acc) => acc === to)
if (targetContractIsInTheList) {
this._unlockContract(to)
}
}
}
ConfirmTxScreen.prototype._unlockContract = function (to) {
const currentKeyring = getCurrentKeyring(to, this.props.network, this.props.keyrings, this.props.identities)
if (ifContractAcc(currentKeyring)) {
this.props.dispatch(actions.showAccountDetail(to))
}
}
function warningIfExists (warning) {
if (warning &&
// Do not display user rejections on this screen:

102
package-lock.json generated
View File

@ -10204,13 +10204,12 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"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#2863c40e0982acfc0b7163f0285d4c56427c7799",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@ -10473,13 +10472,12 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"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#2863c40e0982acfc0b7163f0285d4c56427c7799",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@ -10540,7 +10538,6 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"requires": {
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"ethereumjs-util": "^5.1.1"
},
"dependencies": {
@ -10973,7 +10970,6 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"requires": {
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"ethereumjs-util": "^5.1.1"
},
"dependencies": {
@ -11198,13 +11194,12 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"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#2863c40e0982acfc0b7163f0285d4c56427c7799",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@ -15016,8 +15011,7 @@
"bindings": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz",
"integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==",
"dev": true
"integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw=="
},
"bip39": {
"version": "2.5.0",
@ -15036,7 +15030,6 @@
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz",
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=",
"dev": true,
"requires": {
"safe-buffer": "^5.0.1"
}
@ -15071,8 +15064,7 @@
"bn.js": {
"version": "4.11.8",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
"integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==",
"dev": true
"integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA=="
},
"body-parser": {
"version": "1.18.3",
@ -15115,14 +15107,12 @@
"brorand": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
"dev": true
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8="
},
"browserify-aes": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"dev": true,
"requires": {
"buffer-xor": "^1.0.3",
"cipher-base": "^1.0.0",
@ -15279,8 +15269,7 @@
"buffer-xor": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
"dev": true
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk="
},
"builtin-modules": {
"version": "1.1.1",
@ -15378,7 +15367,6 @@
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
@ -15538,7 +15526,6 @@
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"dev": true,
"requires": {
"cipher-base": "^1.0.1",
"inherits": "^2.0.1",
@ -15551,7 +15538,6 @@
"version": "1.1.7",
"resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"dev": true,
"requires": {
"cipher-base": "^1.0.3",
"create-hash": "^1.1.0",
@ -15851,7 +15837,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz",
"integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=",
"dev": true,
"requires": {
"browserify-aes": "^1.0.6",
"create-hash": "^1.1.2",
@ -15890,7 +15875,6 @@
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",
"integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==",
"dev": true,
"requires": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
@ -16181,14 +16165,12 @@
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"dev": true,
"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#2863c40e0982acfc0b7163f0285d4c56427c7799",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"dev": true,
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@ -16202,6 +16184,14 @@
"integrity": "sha512-XOnAR/3rntJgbCdGhqdaLIxDLWKLmsZOGhHdBKadEr6gEnJLH52k93Ou+TUdFaPN3hJc3isBZBal3U/XZ15abA==",
"dev": true
},
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
}
},
"ethereumjs-block": {
"version": "1.7.1",
"resolved": "http://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-1.7.1.tgz",
@ -16391,7 +16381,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",
@ -16481,7 +16470,6 @@
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz",
"integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==",
"dev": true,
"requires": {
"is-hex-prefixed": "1.0.0",
"strip-hex-prefix": "1.0.0"
@ -16503,7 +16491,6 @@
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz",
"integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==",
"dev": true,
"requires": {
"md5.js": "^1.3.4",
"safe-buffer": "^5.1.1"
@ -16914,7 +16901,6 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz",
"integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
@ -16924,7 +16910,6 @@
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz",
"integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==",
"dev": true,
"requires": {
"inherits": "^2.0.3",
"minimalistic-assert": "^1.0.1"
@ -16952,7 +16937,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
"integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
"dev": true,
"requires": {
"hash.js": "^1.0.3",
"minimalistic-assert": "^1.0.0",
@ -17120,8 +17104,7 @@
"is-hex-prefixed": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz",
"integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=",
"dev": true
"integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ="
},
"is-natural-number": {
"version": "4.0.1",
@ -17175,8 +17158,7 @@
"is-typedarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
},
"is-utf8": {
"version": "0.2.1",
@ -17322,7 +17304,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz",
"integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==",
"dev": true,
"requires": {
"bindings": "^1.2.1",
"inherits": "^2.0.3",
@ -17622,7 +17603,6 @@
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
"integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==",
"dev": true,
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1",
@ -17782,14 +17762,12 @@
"minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==",
"dev": true
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A=="
},
"minimalistic-crypto-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=",
"dev": true
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo="
},
"minimatch": {
"version": "3.0.4",
@ -17841,8 +17819,7 @@
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mz": {
"version": "2.7.0",
@ -17859,8 +17836,7 @@
"nan": {
"version": "2.10.0",
"resolved": "http://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==",
"dev": true
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
},
"nano-json-stream-parser": {
"version": "0.1.2",
@ -18527,7 +18503,6 @@
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz",
"integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==",
"dev": true,
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1"
@ -18537,7 +18512,6 @@
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/rlp/-/rlp-2.1.0.tgz",
"integrity": "sha512-93U7IKH5j7nmXFVg19MeNBGzQW5uXW1pmCuKY8veeKIhYTE32C2d0mOegfiIAfXcHOKJjjPlJisn8iHDF5AezA==",
"dev": true,
"requires": {
"safe-buffer": "^5.1.1"
}
@ -18551,8 +18525,7 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"safe-event-emitter": {
"version": "1.0.1",
@ -18604,7 +18577,6 @@
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.5.2.tgz",
"integrity": "sha512-iin3kojdybY6NArd+UFsoTuapOF7bnJNf2UbcWXaY3z+E1sJDipl60vtzB5hbO/uquBu7z0fd4VC4Irp+xoFVQ==",
"dev": true,
"requires": {
"bindings": "^1.2.1",
"bip66": "^1.1.3",
@ -18736,7 +18708,6 @@
"version": "2.4.11",
"resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
@ -18947,7 +18918,6 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz",
"integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=",
"dev": true,
"requires": {
"is-hex-prefixed": "1.0.0"
}
@ -19191,7 +19161,6 @@
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
"dev": true,
"requires": {
"is-typedarray": "^1.0.0"
}
@ -19634,14 +19603,12 @@
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"dev": true,
"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#2863c40e0982acfc0b7163f0285d4c56427c7799",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"dev": true,
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@ -19649,6 +19616,14 @@
}
}
},
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
}
},
"ws": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
@ -19688,23 +19663,20 @@
"dev": true,
"requires": {
"underscore": "1.8.3",
"web3-core-helpers": "1.0.0-beta.35",
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
"web3-core-helpers": "1.0.0-beta.35"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"dev": true,
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"requires": {
"debug": "^2.2.0",
"nan": "^2.3.3",
@ -19883,8 +19855,7 @@
"yaeti": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=",
"dev": true
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc="
},
"yargs": {
"version": "4.8.1",
@ -39280,7 +39251,6 @@
"resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz",
"integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=",
"requires": {
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"crypto-js": "^3.1.4",
"utf8": "^2.1.1",
"xhr2": "*",
@ -39289,7 +39259,7 @@
"dependencies": {
"bignumber.js": {
"version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git"
"from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934"
}
}
},

View File

@ -2,6 +2,7 @@ const webdriver = require('selenium-webdriver')
const { By } = webdriver
module.exports = {
elements: {
buttonArrow: By.className('fa fa-arrow-left fa-lg cursor-pointer'),
errorClose: By.css('.send-screen > div:nth-child(3) > div:nth-child(1)'),
error: By.className('error'),
loader: By.css('#app-content > div > div.full-flex-height > img'),
@ -31,12 +32,15 @@ module.exports = {
account: {
account1: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(2) > span'),
account2: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(3) > span'),
account3: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(4) > span'),
account4: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(5) > span'),
menu: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div'),
delete: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(4) > div.remove'),
delete: By.className('remove'),
createAccount: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(3) > span'),
// import: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(5) > span'),
import: By.css('li.dropdown-menu-item:nth-child(5) > span:nth-child(1)'),
labelImported: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(4) > div.keyring-label'),
import2: By.css('#app-content > div > div.full-width > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(6)'),
label: By.className('keyring-label'),
},
dot: {
menu: By.className('account-dropdown'),
@ -55,6 +59,7 @@ module.exports = {
titleText: 'Choose contract executor',
buttonNext: By.css('.choose-contract-next-button'),
account: By.className('account-data-subsection flex-row flex-grow'),
addressExecutor: By.className('flex-row flex-center'),
selectedAccount: By.className('executor-cell-container-selected'),
buttonArrow: By.className('fa fa-arrow-left fa-lg cursor-pointer'),
@ -73,7 +78,7 @@ module.exports = {
buttonNext: By.css('.section > div:nth-child(1) > button:nth-child(2)'),
buttonArrow: By.className('fa fa-arrow-left fa-lg cursor-pointer'),
buttonCopyABI: By.className('btn-violet'),
buttonExecuteMethod: By.css('#app-content > div > div.app-primary.from-right > div > div > div.flex-row > button'),
buttonExecuteMethod: By.xpath('//*[@id="app-content"]/div/div[2]/div/div/div[2]/button'),
},
eventsEmitter: {
button: By.className('btn btn-default'),
@ -195,6 +200,8 @@ module.exports = {
button: {
submit: By.css('#pending-tx-form > div.flex-row.flex-space-around.conf-buttons > input'),
reject: By.css('.cancel'),
rejectAll: By.css('#pending-tx-form > div:nth-child(4) > button'),
buyEther: By.css('#pending-tx-form > div.flex-row.flex-space-around.conf-buttons > button.btn-green'),
},
fields: {
gasLimit: By.css('#pending-tx-form > div:nth-child(1) > div.table-box > div:nth-child(3) > div.cell.value > div > div > input'),
@ -233,7 +240,7 @@ module.exports = {
error: By.css('span.error'),
selectArrow: By.className('Select-arrow-zone'),
selectType: By.name('import-type-select'),
itemContract: By.id('react-select-2--option-2'),
itemContract: By.id('react-select-3--option-2'),
contractAddress: By.id('address-box'),
contractABI: By.id('abi-box'),
title: By.css('#app-content > div > div.app-primary.from-right > div > div:nth-child(2) > div.flex-row.flex-center > h2'),
@ -265,6 +272,7 @@ module.exports = {
},
},
main: {
accountAddress: By.xpath('//*[@id="app-content"]/div/div[2]/div/div/div[1]/flex-column/div[2]/div/span'),
identicon: By.className('identicon-wrapper select-none'),
fieldAccountName: By.className('sizing-input'),
accountName: By.className('font-medium color-forest'),
@ -298,6 +306,9 @@ module.exports = {
counterFF: By.css('div.full-flex-height:nth-child(2) > div:nth-child(1) > span:nth-child(1)'),
},
},
buyEther: {
title: By.className('flex-center buy-title'),
},
info: {
title: By.className('section-title flex-row flex-center'),
titleText: 'Info',

View File

@ -12,10 +12,11 @@ const { menus, screens, elements, NETWORKS } = require('./elements')
const testSeedPhrase = 'horn among position unable audit puzzle cannon apology gun autumn plug parrot'
const account1 = '0x2E428ABd9313D256d64D1f69fe3929C3BE18fD1f'
const account2 = '0xd7b7AFeCa35e32594e29504771aC847E2a803742'
const accountsWallet = []
const eventsEmitter = 'https://vbaranov.github.io/event-listener-dapp/'
describe('Metamask popup page', async function () {
let driver, accountAddress, tokenAddress, extensionId
let driver, tokenAddress, extensionId
let password = '123456789'
let abiClipboard
const newPassword = {
@ -76,8 +77,7 @@ describe('Metamask popup page', async function () {
})
})
describe('Account Creation', async () => {
const newAccountName = 'new name'
describe('Log In', async () => {
it('title is \'Nifty Wallet\'', async () => {
const title = await driver.getTitle()
@ -130,6 +130,9 @@ describe('Metamask popup page', async function () {
assert.equal(await continueAfterSeedPhrase.getText(), screens.seedPhrase.textButtonIveCopied)
await click(continueAfterSeedPhrase)
})
})
describe('Account Creation', async () => {
const newAccountName = 'new name'
it('sets provider type to localhost', async function () {
await setProvider(NETWORKS.LOCALHOST)
@ -142,6 +145,12 @@ describe('Metamask popup page', async function () {
assert.notEqual(field, false, 'copy icon doesn\'t present')
})
it("Account's address is displayed and has length 20 symbols", async () => {
const field = await waitUntilShowUp(screens.main.address)
accountsWallet.push((await field.getText()).toUpperCase())
console.log(accountsWallet[0])
assert.notEqual(accountsWallet[0].length, 20, "address isn't displayed")
})
it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.length, 42, "address account wasn't copied to clipboard")
@ -187,10 +196,11 @@ describe('Metamask popup page', async function () {
await item.click()
})
it('shows account address', async function () {
await delay(300)
const account = await waitUntilShowUp(screens.main.address)
accountAddress = await account.getText()
it("Account's address is displayed and has length 20 symbols", async () => {
const field = await waitUntilShowUp(screens.main.address)
accountsWallet.push((await field.getText()).toUpperCase())
console.log(accountsWallet[1])
assert.notEqual(accountsWallet[1].length, 20, "address isn't displayed")
})
it('logs out of the vault', async () => {
@ -220,7 +230,7 @@ describe('Metamask popup page', async function () {
it('checks QR code address is the same as account details address', async () => {
const field = await waitUntilShowUp(screens.QRcode.address)
const text = await field.getText()
assert.equal(text.toLowerCase(), accountAddress.toLowerCase(), 'QR addres doesn\'t match')
assert.equal(text.toUpperCase(), accountsWallet[1], 'QR address doesn\'t match')
})
it('copy icon is displayed and clickable', async () => {
@ -255,18 +265,75 @@ describe('Metamask popup page', async function () {
await button.click()
})
})
describe('Import Account', () => {
it('Open import account menu', async function () {
await setProvider(NETWORKS.POA)
await delay(2000)
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
const item = await waitUntilShowUp(menus.account.import)
await item.click()
const importAccountTitle = await waitUntilShowUp(screens.importAccounts.title)
assert.equal(await importAccountTitle.getText(), screens.importAccounts.textTitle)
})
it('Imports account', async function () {
const privateKeyBox = await waitUntilShowUp(screens.importAccounts.fieldPrivateKey)
await privateKeyBox.sendKeys('76bd0ced0a47055bb5d060e1ae4a8cb3ece658d668823e250dae6e79d3ab4435')// 0xf4702CbA917260b2D6731Aea6385215073e8551b
accountsWallet.push('0xf4702CbA917260b2D6731Aea6385215073e8551b'.toUpperCase())
const button = await waitUntilShowUp(screens.importAccounts.buttonImport)
await click(button)
assert.equal(await button.getText(), 'Import', 'button has incorrect name')
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
await waitUntilShowUp(menus.account.label)
const label = (await driver.findElements(menus.account.label))[0]
assert.equal(await label.getText(), 'IMPORTED')
await menu.click()
})
it('Auto-detect tokens for POA core network ', async function () {
// await setProvider(NETWORKS.POA)
const tab = await waitUntilShowUp(screens.main.tokens.menu)
await tab.click()
const balance = await waitUntilShowUp(screens.main.tokens.balance)
console.log(await balance.getText())
assert.equal(await balance.getText(), '1 DOPR', 'token isnt\' auto-detected')
})
it.skip('Auto-detect tokens for MAIN core network ', async function () {
await setProvider(NETWORKS.MAINNET)
await waitUntilShowUp(elements.loader, 25)
await waitUntilDisappear(elements.loader, 25)
const balance = await waitUntilShowUp(screens.main.tokens.balance)
console.log(await balance.getText())
assert.equal(await balance.getText(), '0.001 WETH', 'token isnt\' auto-detected')
})
it('Check Sokol balance', async function () {
await setProvider(NETWORKS.POA)
await delay(2000)
const balanceField = await waitUntilShowUp(screens.main.balance)
const balance = await balanceField.getText()
console.log('Account = 0xf4702CbA917260b2D6731Aea6385215073e8551b')
console.log('Balance = ' + balance)
assert.equal(parseFloat(balance) > 0.001, true, 'Balance of account 0xf4702CbA917260b2D6731Aea6385215073e8551b TOO LOW !!! Please refill with Sokol eth!!!!')
})
})
describe('Import Contract account', async () => {
const contractSokol = '0x215b2ab35749e5a9f3efe890de602fb9844e842f'
const contractSokol = '0x61449bb37db034b2394cd62da545611f71cf54d5'
console.log('Contract ' + contractSokol + ' , Sokol')
const wrongAddress = '0xB87b6077D59B01Ab9fa8cd5A1A21D02a4d60D35'
const notContractAddress = '0x56B2e3C3cFf7f3921Dc2e0F8B8e20d1eEc29216b'
describe('Import Contract', async () => {
it('opens import account menu', async function () {
await setProvider(NETWORKS.ROPSTEN)
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
const item = await waitUntilShowUp(menus.account.import)
const item = await waitUntilShowUp(menus.account.import2)
await item.click()
const importAccountTitle = await waitUntilShowUp(screens.importAccounts.title)
assert.equal(await importAccountTitle.getText(), screens.importAccounts.textTitle)
@ -286,7 +353,6 @@ describe('Metamask popup page', async function () {
})
it("Field 'Address' is displayed", async function () {
await delay(2000)
const field = await waitUntilShowUp(screens.importAccounts.contractAddress)
assert.notEqual(field, false, "field 'Address' isn't displayed")
await field.sendKeys(wrongAddress)
@ -339,7 +405,7 @@ describe('Metamask popup page', async function () {
it('ABI is fetched ', async function () {
const field = await waitUntilShowUp(screens.importAccounts.contractABI)
abiClipboard = await field.getText()
assert.equal(abiClipboard.length, 4457, "ABI isn't fetched")
assert.equal(abiClipboard.length, 4927, "ABI isn't fetched")
})
it('icon copy is displayed for ABI ', async function () {
@ -390,6 +456,7 @@ describe('Metamask popup page', async function () {
})
describe('Execute Method screen', () => {
const amountMethods = 25
const notContractAddress = '0x56B2e3C3cFf7f3921Dc2e0F8B8e20d1eEc29216b'
describe("Check UI and button's functionality", () => {
@ -432,8 +499,8 @@ describe('Metamask popup page', async function () {
await field.click()
await waitUntilShowUp(screens.executeMethod.items)
const list = await driver.findElements(screens.executeMethod.items)
await list[3].click()
assert.equal(list.length, 22, "drop down menu isn't displayed")
await list[6].click()
assert.equal(list.length, amountMethods, "drop down menu isn't displayed")
})
it("Button 'Call data' is displayed and disabled", async function () {
@ -495,8 +562,8 @@ describe('Metamask popup page', async function () {
await field.click()
await waitUntilShowUp(screens.executeMethod.items)
const list = await driver.findElements(screens.executeMethod.items)
await list[14].click()
assert.equal(list.length, 22, "drop down menu isn't displayed")
await list[17].click()
assert.equal(list.length, amountMethods, "drop down menu isn't displayed")
})
it('Fill out input parameter field ', async function () {
@ -537,8 +604,8 @@ describe('Metamask popup page', async function () {
await field.click()
await waitUntilShowUp(screens.executeMethod.items)
const list = await driver.findElements(screens.executeMethod.items)
await list[5].click()
assert.equal(list.length, 22, "drop down menu isn't displayed")
await list[8].click()
assert.equal(list.length, amountMethods, "drop down menu isn't displayed")
})
it('Select value TRUE from dropdown menu', async function () {
@ -612,8 +679,8 @@ describe('Metamask popup page', async function () {
await field.click()
await waitUntilShowUp(screens.executeMethod.items)
const list = await driver.findElements(screens.executeMethod.items)
await list[7].click()
assert.equal(list.length, 22, "drop down menu isn't displayed")
await list[10].click()
assert.equal(list.length, amountMethods, "drop down menu isn't displayed")
})
it('Fill out input parameter field ', async function () {
@ -658,8 +725,8 @@ describe('Metamask popup page', async function () {
await field.click()
await waitUntilShowUp(screens.executeMethod.items)
const list = await driver.findElements(screens.executeMethod.items)
await list[17].click()
assert.equal(list.length, 22, "drop down menu isn't displayed")
await list[20].click()
assert.equal(list.length, amountMethods, "drop down menu isn't displayed")
})
it('Fill out input parameter field ', async function () {
@ -705,8 +772,8 @@ describe('Metamask popup page', async function () {
await field.click()
await waitUntilShowUp(screens.executeMethod.items)
const list = await driver.findElements(screens.executeMethod.items)
await list[10].click()
assert.equal(list.length, 22, "drop down menu isn't displayed")
await list[13].click()
assert.equal(list.length, amountMethods, "drop down menu isn't displayed")
})
it('Fill out input parameter field ', async function () {
@ -749,8 +816,8 @@ describe('Metamask popup page', async function () {
await field.click()
await waitUntilShowUp(screens.executeMethod.items)
const list = await driver.findElements(screens.executeMethod.items)
await list[21].click()
assert.equal(list.length, 22, "drop down menu isn't displayed")
await list[24].click()
assert.equal(list.length, amountMethods, "drop down menu isn't displayed")
})
it("Button 'Copy ABI encoded' is displayed", async function () {
@ -847,21 +914,30 @@ describe('Metamask popup page', async function () {
})
describe('Choose Contract Executor', () => {
it('title is displayed and correct', async function () {
it('Title is displayed and correct', async function () {
await delay(5000)
const title = await waitUntilShowUp(screens.chooseContractExecutor.title)
assert.notEqual(title, false, 'title isn\'t displayed')
assert.equal(await title.getText(), screens.chooseContractExecutor.titleText, 'incorrect text')
})
it('two accounts displayed', async function () {
it('Three accounts are displayed', async function () {
const accs = await waitUntilShowUp(screens.chooseContractExecutor.account)
assert.notEqual(accs, false, 'accounts aren\'t displayed')
assert.notEqual(accs, false, "accounts aren't displayed")
const accounts = await driver.findElements(screens.chooseContractExecutor.account)
assert.equal(accounts.length, 3, "number of accounts isn't 2")
assert.equal(accounts.length, 4, "number of accounts isn't 3")
})
it("Click arrow button leads to 'Execute Method' screen ", async function () {
it("Owner's account first in the list of executors", async function () {
const accs = await waitUntilShowUp(screens.chooseContractExecutor.addressExecutor)
assert.notEqual(accs, false, "addresses aren't displayed")
const addresses = await driver.findElements(screens.chooseContractExecutor.addressExecutor)
const address = await addresses[2].getText()
const souldBe = accountsWallet[2].slice(0, 10) + '...' + accountsWallet[2].slice(accountsWallet[2].length - 4, accountsWallet[2].length)
assert.equal(address.toUpperCase(), souldBe, "owner isn't first in the list")
})
it("Click arrow button leads to 'Execute Method' screen ", async function () {
const button = await waitUntilShowUp(screens.chooseContractExecutor.buttonArrow)
assert.notEqual(button, false, 'button isn\'t displayed')
await button.click()
@ -885,8 +961,10 @@ describe('Metamask popup page', async function () {
})
it('User is able to select account', async function () {
await delay(2000)
await waitUntilShowUp(screens.chooseContractExecutor.account)
const accounts = await driver.findElements(screens.chooseContractExecutor.account)
console.log(accounts.length)
const account = accounts[1]
await account.click()
const selected = await driver.findElements(screens.chooseContractExecutor.selectedAccount)
@ -896,30 +974,95 @@ describe('Metamask popup page', async function () {
it('User is able to select only one account', async function () {
const account = (await driver.findElements(screens.chooseContractExecutor.account))[2]
await account.click()
await delay(20000)
const selected = await driver.findElements(screens.chooseContractExecutor.selectedAccount)
assert.equal(selected.length, 1, 'more than one accounts are selected')
})
it("Click button 'Next' open 'Confirm transaction' screen", async function () {
const button = await waitUntilShowUp(screens.chooseContractExecutor.buttonNext)
await button.click()
await delay(5000)
await delay(3000)
const reject = await waitUntilShowUp(screens.confirmTransaction.button.reject)
assert.notEqual(reject, false, "button reject isn't displayed")
await click(reject)
const identicon = await waitUntilShowUp(screens.main.identicon)
assert.notEqual(identicon, false, 'main screen didn\'t opened')
})
it("Label 'CONTRACT' present", async function () {
it("Button 'Buy Ether' is displayed", async function () {
const button = await waitUntilShowUp(screens.confirmTransaction.button.buyEther)
assert.equal(await button.getText(), 'Buy Ether', 'button has incorrect name')
assert.equal(await button.isEnabled(), true, 'button is disabled')
})
it("Open screen 'Buy Ether'", async function () {
const button = await waitUntilShowUp(screens.confirmTransaction.button.buyEther)
await button.click()
const title = await waitUntilShowUp(screens.buyEther.title)
assert.equal(await title.getText(), 'Buy POA', "screen 'Buy Ether' has incorrect title text")
const arrow = await waitUntilShowUp(elements.buttonArrow)
await arrow.click()
})
it("Click button 'Reject' open contract's account screen", async function () {
const reject = await waitUntilShowUp(screens.confirmTransaction.button.reject)
assert.equal(await reject.getText(), 'Reject', 'button has incorrect name')
await reject.click()
const buttonExecute = await waitUntilShowUp(screens.executeMethod.buttonExecuteMethod)
assert.notEqual(buttonExecute, false, "contract's account hasn't opened")
})
it("Button arrow leads to executor's account screen", async function () {
assert.equal(await executeTransferMethod(1), true, "can't execute the method 'transfer'")
await delay(2000)
const arrow = await waitUntilShowUp(elements.buttonArrow)
await arrow.click()
await delay(2000)
const address = await waitUntilShowUp(screens.main.address)
assert.equal((await address.getText()).toUpperCase(), accountsWallet[0], "executors account isn't opened")
})
it('Switch to contract account ', async function () {
const accountMenu = await waitUntilShowUp(menus.account.menu)
await accountMenu.click()
const item = await waitUntilShowUp(menus.account.account4)
await item.click()
await delay(2000)
const address = await waitUntilShowUp(screens.main.address)
assert.equal((await address.getText()).toUpperCase(), contractSokol.toUpperCase(), "contract's account isn't opened")
})
it("Confirm transaction: button 'Reject All' leads to contract's account screen", async function () {
assert.equal(await executeTransferMethod(1), true, "can't execute the method 'transfer'")
const rejectAll = await waitUntilShowUp(screens.confirmTransaction.button.rejectAll)
assert.equal(await rejectAll.getText(), 'Reject All', 'button has incorrect name')
await rejectAll.click()
await delay(2000)
const address = await waitUntilShowUp(screens.main.address)
assert.equal((await address.getText()).toUpperCase(), contractSokol.toUpperCase(), "contract account isn't opened")
})
it("Confirm transaction: button 'Submit' leads to contract's account screen", async function () {
assert.equal(await executeTransferMethod(0), true, "can't execute the method 'transfer'")
await delay(2000)
const button = await waitUntilShowUp(screens.confirmTransaction.button.submit)
// assert.equal(await button.getText(), 'Submit', "button has incorrect name")
await button.click()
await delay(2000)
const address = await waitUntilShowUp(screens.main.address)
assert.equal((await address.getText()).toUpperCase(), contractSokol.toUpperCase(), "contract account isn't opened")
})
it("Label 'CONTRACT' present", async function () {
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
await waitUntilShowUp(menus.account.labelImported)
const label = (await driver.findElements(menus.account.labelImported))[0]
await waitUntilShowUp(menus.account.label)
const label = (await driver.findElements(menus.account.label))[1]
assert.equal(await label.getText(), 'CONTRACT', 'label incorrect')
})
it('Delete imported account', async function () {
const item = await waitUntilShowUp(menus.account.delete)
await item.click()
await waitUntilShowUp(menus.account.delete)
const items = await driver.findElements(menus.account.delete)
await items[1].click()
const button = await waitUntilShowUp(screens.deleteImportedAccount.buttons.yes)
await button.click()
const buttonArrow = await waitUntilShowUp(screens.settings.buttons.arrow)
@ -929,10 +1072,60 @@ describe('Metamask popup page', async function () {
})
})
})
describe('Delete Imported Account', () => {
it('Open delete imported account screen', async function () {
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
const item = await waitUntilShowUp(menus.account.delete)
await item.click()
const deleteImportedAccountTitle = await waitUntilShowUp(screens.deleteImportedAccount.title)
assert.equal(await deleteImportedAccountTitle.getText(), screens.deleteImportedAccount.titleText)
})
it("Can't remove imported account with 'No' button", async function () {
const button = await waitUntilShowUp(screens.deleteImportedAccount.buttons.no)
assert.equal(await button.getText(), 'No', 'button has incorrect name')
await click(button)
const settingsTitle = await waitUntilShowUp(screens.settings.title)
assert.equal(await settingsTitle.getText(), 'Settings')
// check, that imported account still exists
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
await delay(2000)
const label = await waitUntilShowUp(menus.account.label)
assert.equal(await label.getText(), 'IMPORTED')
})
it('Open delete imported account screen again', async function () {
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
await delay(2000)
await menu.click()
await waitUntilShowUp(menus.account.delete)
const buttons = await driver.findElements(menus.account.delete)
assert.notEqual(buttons[0], false, "icon 'remove' isn't displayed")
await buttons[0].click()
})
it("Remove imported account with 'Yes' button", async function () {
const button = await waitUntilShowUp(screens.deleteImportedAccount.buttons.yes)
assert.equal(await button.getText(), 'Yes', 'button has incorrect name')
await click(button)
const settingsTitle = await waitUntilShowUp(screens.settings.title)
assert.equal(await settingsTitle.getText(), 'Settings')
// check, that imported account is removed
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
await waitUntilShowUp(menus.account.label, 25)
const labels = await driver.findElements(menus.account.label)
assert.ok(labels.length === 0)
await menu.click()
})
})
describe('Sign Data', () => {
it('simulate sign request ', async function () {
it('Simulate sign request ', async function () {
await setProvider(NETWORKS.LOCALHOST)
await driver.get('https://danfinlay.github.io/js-eth-personal-sign-examples/')
const button = await waitUntilShowUp(By.id('ethSignButton'))
@ -958,7 +1151,7 @@ describe('Metamask popup page', async function () {
it('account name is displayed and correct', async function () {
const name = await waitUntilShowUp(screens.signMessage.accountName)
assert.notEqual(name, false, 'account name isn\'t displayed')
assert.equal(await name.getText(), 'Account 2', 'account name is incorrect')
assert.equal(await name.getText(), 'new name', 'account name is incorrect')
})
it('title is displayed and correct', async function () {
@ -988,94 +1181,7 @@ describe('Metamask popup page', async function () {
assert.notEqual(identicon, false, 'main screen didn\'t opened')
})
})
describe('Import Account', () => {
it('opens import account menu', async function () {
await setProvider(NETWORKS.POA)
await delay(2000)
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
const item = await waitUntilShowUp(menus.account.import)
await item.click()
const importAccountTitle = await waitUntilShowUp(screens.importAccounts.title)
assert.equal(await importAccountTitle.getText(), screens.importAccounts.textTitle)
})
it('imports account', async function () {
const privateKeyBox = await waitUntilShowUp(screens.importAccounts.fieldPrivateKey)
await privateKeyBox.sendKeys('76bd0ced0a47055bb5d060e1ae4a8cb3ece658d668823e250dae6e79d3ab4435')// 0xf4702CbA917260b2D6731Aea6385215073e8551b
const button = await waitUntilShowUp(screens.importAccounts.buttonImport)
await click(button)
assert.equal(await button.getText(), 'Import', 'button has incorrect name')
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
await waitUntilShowUp(menus.account.labelImported)
const label = (await driver.findElements(menus.account.labelImported))[0]
assert.equal(await label.getText(), 'IMPORTED')
await menu.click()
})
it('Auto-detect tokens for POA core network ', async function () {
// await setProvider(NETWORKS.POA)
const tab = await waitUntilShowUp(screens.main.tokens.menu)
await tab.click()
const balance = await waitUntilShowUp(screens.main.tokens.balance)
console.log(await balance.getText())
assert.equal(await balance.getText(), '1 DOPR', 'token isnt\' auto-detected')
})
it.skip('Auto-detect tokens for MAIN core network ', async function () {
await setProvider(NETWORKS.MAINNET)
await waitUntilShowUp(elements.loader, 25)
await waitUntilDisappear(elements.loader, 25)
const balance = await waitUntilShowUp(screens.main.tokens.balance)
console.log(await balance.getText())
assert.equal(await balance.getText(), '0.001 WETH', 'token isnt\' auto-detected')
})
it('opens delete imported account screen', async function () {
await setProvider(NETWORKS.LOCALHOST)
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
const item = await waitUntilShowUp(menus.account.delete)
await item.click()
const deleteImportedAccountTitle = await waitUntilShowUp(screens.deleteImportedAccount.title)
assert.equal(await deleteImportedAccountTitle.getText(), screens.deleteImportedAccount.titleText)
})
it('doesn\'t remove imported account with \'No\' button', async function () {
const button = await waitUntilShowUp(screens.deleteImportedAccount.buttons.no)
assert.equal(await button.getText(), 'No', 'button has incorrect name')
await click(button)
const settingsTitle = await waitUntilShowUp(screens.settings.title)
assert.equal(await settingsTitle.getText(), 'Settings')
// check, that imported account still exists
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
const importedLabel = await waitUntilShowUp(menus.account.labelImported)
assert.equal(await importedLabel.getText(), 'IMPORTED')
})
it('opens delete imported account screen again', async function () {
const menu = await waitUntilShowUp(menus.account.delete)
await menu.click()
})
it('removes imported account with \'Yes\' button', async function () {
const button = await waitUntilShowUp(screens.deleteImportedAccount.buttons.yes)
assert.equal(await button.getText(), 'Yes', 'button has incorrect name')
await click(button)
const settingsTitle = await waitUntilShowUp(screens.settings.title)
assert.equal(await settingsTitle.getText(), 'Settings')
// check, that imported account is removed
const menu = await waitUntilShowUp(menus.account.menu)
await menu.click()
await waitUntilShowUp(menus.account.labelImported, 25)
const importedAccounts = await driver.findElements(menus.account.labelImported)
assert.ok(importedAccounts.length === 0)
await menu.click()
})
})
describe('Export private key', async () => {
it('open dialog', async function () {
@ -2936,6 +3042,45 @@ describe('Metamask popup page', async function () {
return contractInstance.address
}
async function executeTransferMethod (executor) {
try {
const buttonExecute = await waitUntilShowUp(screens.executeMethod.buttonExecuteMethod)
assert.notEqual(buttonExecute, false, "button doesn't displayed")
await buttonExecute.click()
// Select method transfer
const menu = await waitUntilShowUp(screens.executeMethod.selectArrow)
await menu.click()
await waitUntilShowUp(screens.executeMethod.items)
const list = await driver.findElements(screens.executeMethod.items)
await list[24].click()
// Fill out value
await waitUntilShowUp(screens.executeMethod.fieldParameter)
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
assert.notEqual(fields[1], false, "field value isn't displayed")
await fields[1].sendKeys('1')
// Fill out address
await clearField(fields[0], 100)
await fields[0].sendKeys(account1)
assert.notEqual(fields[0], false, "field address isn't displayed")
// Click button next
const buttonNext = await waitUntilShowUp(screens.executeMethod.buttonNext)
assert.notEqual(buttonNext, false, "button 'Next' isn't displayed")
await buttonNext.click()
// Select executor
await delay(2000)
await waitUntilShowUp(screens.chooseContractExecutor.account)
const accounts = await driver.findElements(screens.chooseContractExecutor.account)
const account = accounts[executor + 1]
await account.click()
// Open confirm transaction
const button = await waitUntilShowUp(screens.chooseContractExecutor.buttonNext)
await button.click()
return true
} catch (err) {
return false
}
}
})

View File

@ -813,7 +813,12 @@ describe('Actions', () => {
const store = mockStore()
const expectedActions = [
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_CONF_TX_PAGE', transForward: true, id: undefined, value: {} },
{
type: 'SHOW_CONF_TX_PAGE',
transForward: true,
id: undefined,
value: {isContractExecutionByUser: undefined},
},
]
sendTransactionSpy.callsFake((txData, callback) => {
callback(new Error('error'))

View File

@ -954,7 +954,7 @@ function signTx (txData) {
return dispatch(actions.displayWarning(err.message))
}
})
dispatch(actions.showConfTxPage({}))
dispatch(actions.showConfTxPage({isContractExecutionByUser: txData && txData.isContractExecutionByUser}))
}
}
@ -2278,10 +2278,13 @@ function onboardingBuyEthView (address) {
}
}
function buyEthView (address) {
function buyEthView (address, isContractExecutionByUser) {
return {
type: actions.BUY_ETH_VIEW,
value: address,
value: {
address,
isContractExecutionByUser,
},
}
}

View File

@ -695,11 +695,12 @@ function reduceApp (state, action) {
name: 'buyEth',
context: appState.currentView.name,
},
identity: state.metamask.identities[action.value],
identity: state.metamask.identities[action.value.address],
buyView: {
subview: 'Coinbase',
amount: '15.00',
buyAddress: action.value,
buyAddress: action.value.address,
isContractExecutionByUser: action.value.isContractExecutionByUser,
formView: {
coinbase: true,
shapeshift: false,