move isHexadecimal to helpers.js

pull/1/head
LianaHus 5 years ago committed by Liana Husikyan
parent 08a807d6c5
commit d2d2d9e385
  1. 12
      src/app/ui/universal-dapp-ui.js
  2. 6
      src/lib/helper.js
  3. 5
      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,8 +11,8 @@ 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'
.testContracts('browser/receiveAndfFallback.sol', sources[0]['receiveAndfFallback.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp')
.selectContract('CheckSpecials')
.createContract('')
.clickInstance(0)
@ -25,7 +25,6 @@ module.exports = {
.perform(done)
})
})
)
},
tearDown: sauce
}

Loading…
Cancel
Save