Commit d2d2d9e3 authored by LianaHus's avatar LianaHus Committed by Liana Husikyan

move isHexadecimal to helpers.js

parent 08a807d6
...@@ -178,7 +178,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address ...@@ -178,7 +178,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
const amount = document.querySelector('#value').value const amount = document.querySelector('#value').value
if (amount !== '0') { if (amount !== '0') {
// check for numeric and receive/fallback // check for numeric and receive/fallback
if (!isNumeric(amount)) { if (!helper.isNumeric(amount)) {
setLLIError('Value to send should be a number') setLLIError('Value to send should be a number')
} else if (!receive && !(fallback && fallback.stateMutability === 'payable')) { } else if (!receive && !(fallback && fallback.stateMutability === 'payable')) {
setLLIError("In order to receive Ether transfer the contract should have either 'receive' or payable 'fallback' function") 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 ...@@ -186,7 +186,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
} }
if (calldata) { if (calldata) {
if (calldata.length > 3 && calldata.substr(0, 2) === '0x') { 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.') setLLIError('the calldata should be a valid hexadecimal value.')
} }
} }
...@@ -197,14 +197,6 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address ...@@ -197,14 +197,6 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
if ((calldata || amount !== '0') && !error) self.runTransaction(false, args, null, calldata, null) 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) contractActionsWrapper.appendChild(lowLevelInteracions)
return instance return instance
} }
......
...@@ -44,6 +44,12 @@ module.exports = { ...@@ -44,6 +44,12 @@ module.exports = {
checkSpecialChars (name) { checkSpecialChars (name) {
return name.match(/[:*?"<>\\'|]/) != null return name.match(/[:*?"<>\\'|]/) != null
}, },
isHexadecimal (value) {
return /^[0-9a-fA-F]+$/.test(value)
},
isNumeric (value) {
return /^\+?(0|[1-9]\d*)$/.test(value)
},
find: find find: find
} }
......
...@@ -11,21 +11,20 @@ module.exports = { ...@@ -11,21 +11,20 @@ module.exports = {
}, },
'Use special functions receive/fullback': function (browser) { 'Use special functions receive/fullback': function (browser) {
browser.waitForElementVisible('#icon-panel', 10000) browser.waitForElementVisible('#icon-panel', 10000)
.testContracts('receiveAndfFallback.sol', sources[0]['browser/Untitled.sol'], ['CheckSpecials']) .testContracts('browser/receiveAndfFallback.sol', sources[0]['receiveAndfFallback.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp' .clickLaunchIcon('udapp')
.selectContract('CheckSpecials') .selectContract('CheckSpecials')
.createContract('') .createContract('')
.clickInstance(0) .clickInstance(0)
.perform((done) => { .perform((done) => {
browser.getAddressAtPosition(0, (address) => { browser.getAddressAtPosition(0, (address) => {
browser.sendLowLevelTx(address, '0', '0xaa') browser.sendLowLevelTx(address, '0', '0xaa')
.journalLastChild('dd') .journalLastChild('dd')
.waitForElementVisible('label[id="deployAndRunLLTxError"]') .waitForElementVisible('label[id="deployAndRunLLTxError"]')
.assert.containsText('label[id="deployAndRunLLTxError"]', '') .assert.containsText('label[id="deployAndRunLLTxError"]', '')
.perform(done) .perform(done)
})
}) })
) })
}, },
tearDown: sauce tearDown: sauce
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment