Initial commit to check for valid address

pull/1/head
Eswara Sai 7 years ago
parent 938d03b66f
commit 1aa2e45219
  1. 7
      src/app/tabs/run-tab.js
  2. 8
      test-browser/helpers/contracts.js
  3. 10
      test-browser/tests/ballot.js

@ -12,6 +12,7 @@ var copyToClipboard = require('../ui/copy-to-clipboard')
var Recorder = require('../../recorder')
var EventManager = remixLib.EventManager
var addTooltip = require('../ui/tooltip')
var ethJSUtil = require('ethereumjs-util')
var csjs = require('csjs-inject')
var css = require('./styles/run-tab-styles')
@ -311,6 +312,12 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) {
noInstancesText.style.display = 'none'
var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)
var address = atAddressButtonInput.value
if (!ethJSUtil.isValidAddress(address)) {
return modalDialogCustom.alert('Invalid address.')
}
if (/[a-f]/.test(address) && /[A-F]/.test(address) && !ethJSUtil.isValidChecksumAddress(address)) {
return modalDialogCustom.alert('Invalid checksum address.')
}
if (/.(.abi)$/.exec(appAPI.currentFile())) {
modalDialogCustom.confirm(null, 'Do you really want to interact with ' + address + ' using the current ABI definition ?', () => {
var abi

@ -1,5 +1,6 @@
'use strict'
var deepequal = require('deep-equal')
var ethJSUtil = require('ethereumjs-util')
module.exports = {
getCompiledContracts: getCompiledContracts,
@ -161,11 +162,16 @@ function setEditorValue (value, callback) {
return this
}
function addInstance (browser, address, callback) {
function addInstance(browser, address, isValidFormat, isValidChecksum, callback) {
browser.setValue('.ataddressinput', address, function () {
browser.click('div[class^="atAddress"]')
.perform((client, done) => {
browser.execute(function () {
if (!isValidFormat) {
browser.assert.fail(document.querySelector('div[class^="modalBody"] div').innerHTML, 'Invalid address.', '')
} else if (!isValidChecksum) {
browser.assert.fail(document.querySelector('div[class^="modalBody"] div').innerHTML, 'Invalid checksum address.', '')
}
document.querySelector('#modal-footer-ok').click()
}, [], function (result) {
done()

@ -72,8 +72,14 @@ function runTests (browser, testData) {
})
})
.perform((client, done) => {
console.log('addInstance 0x692a70d2e424a56d2c6c27aa97d1a86395877b3a')
contractHelper.addInstance(browser, '0x692a70d2e424a56d2c6c27aa97d1a86395877b3a', () => {
console.log('addInstance invalid checksum address 0x692a70d2e424a56d2c6c27aa97d1a86395877b3a')
contractHelper.addInstance(browser, '0x692a70d2e424a56d2c6c27aa97d1a86395877b3a', true, false, () => {
done()
})
})
.perform((client, done) => {
console.log('addInstance 0x692a70D2e424a56D2C6C27aA97D1a86395877b3A')
contractHelper.addInstance(browser, '0x692a70D2e424a56D2C6C27aA97D1a86395877b3A', true, true, () => {
done()
})
})

Loading…
Cancel
Save