move isHexadecimal to helpers.js

pull/5370/head
LianaHus 5 years ago committed by Liana Husikyan
parent 69e2364d7b
commit 24f4943854
  1. 12
      src/app/ui/universal-dapp-ui.js
  2. 6
      src/lib/helper.js
  3. 27
      test-browser/tests/specialFunctions.js

@ -178,7 +178,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
const amount = document.querySelector('#value').value
if (amount !== '0') {
// check for numeric and receive/fallback
if (!isNumeric(amount)) {
if (!helper.isNumeric(amount)) {
setLLIError('Value to send should be a number')
} else if (!receive && !(fallback && fallback.stateMutability === 'payable')) {
setLLIError("In order to receive Ether transfer the contract should have either 'receive' or payable 'fallback' function")
@ -186,7 +186,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
}
if (calldata) {
if (calldata.length > 3 && calldata.substr(0, 2) === '0x') {
if (!isHexadecimal(calldata.substr(2, calldata.length))) {
if (!helper.isHexadecimal(calldata.substr(2, calldata.length))) {
setLLIError('the calldata should be a valid hexadecimal value.')
}
}
@ -197,14 +197,6 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
if ((calldata || amount !== '0') && !error) self.runTransaction(false, args, null, calldata, null)
}
function isHexadecimal (value) {
return /^[0-9a-fA-F]+$/.test(value)
}
function isNumeric (value) {
return /^\+?(0|[1-9]\d*)$/.test(value)
}
contractActionsWrapper.appendChild(lowLevelInteracions)
return instance
}

@ -44,6 +44,12 @@ module.exports = {
checkSpecialChars (name) {
return name.match(/[:*?"<>\\'|]/) != null
},
isHexadecimal (value) {
return /^[0-9a-fA-F]+$/.test(value)
},
isNumeric (value) {
return /^\+?(0|[1-9]\d*)$/.test(value)
},
find: find
}

@ -11,21 +11,20 @@ module.exports = {
},
'Use special functions receive/fullback': function (browser) {
browser.waitForElementVisible('#icon-panel', 10000)
.testContracts('receiveAndfFallback.sol', sources[0]['browser/Untitled.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp'
.selectContract('CheckSpecials')
.createContract('')
.clickInstance(0)
.perform((done) => {
browser.getAddressAtPosition(0, (address) => {
browser.sendLowLevelTx(address, '0', '0xaa')
.journalLastChild('dd')
.waitForElementVisible('label[id="deployAndRunLLTxError"]')
.assert.containsText('label[id="deployAndRunLLTxError"]', '')
.perform(done)
})
.testContracts('browser/receiveAndfFallback.sol', sources[0]['receiveAndfFallback.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp')
.selectContract('CheckSpecials')
.createContract('')
.clickInstance(0)
.perform((done) => {
browser.getAddressAtPosition(0, (address) => {
browser.sendLowLevelTx(address, '0', '0xaa')
.journalLastChild('dd')
.waitForElementVisible('label[id="deployAndRunLLTxError"]')
.assert.containsText('label[id="deployAndRunLLTxError"]', '')
.perform(done)
})
)
})
},
tearDown: sauce
}

Loading…
Cancel
Save