Merge pull request #700 from ethereum/atAddressAbi

use "At address" when the content is abi
pull/1/head
yann300 7 years ago committed by GitHub
commit ed18788657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/app.js
  2. 4
      src/app/execution/txHelper.js
  3. 14
      src/app/tabs/run-tab.js
  4. 14
      src/lib/helper.js
  5. 9
      src/universal-dapp.js
  6. 16
      test-browser/helpers/contracts.js
  7. 15
      test-browser/tests/ballot.js

@ -538,6 +538,12 @@ function run () {
getSource: (fileName) => {
return compiler.getSource(fileName)
},
editorContent: () => {
return editor.get(editor.current())
},
currentFile: () => {
return config.get('currentFile')
},
getContracts: () => {
return compiler.getContracts()
},
@ -687,8 +693,11 @@ function run () {
if (transactionDebugger.isActive) return
fileManager.saveCurrentFile()
editor.clearAnnotations()
var currentFile = config.get('currentFile')
if (currentFile) {
if (/.(.sol)$/.exec(currentFile)) {
// only compile *.sol file.
var target = currentFile
var sources = {}
var provider = fileManager.fileProviderOf(currentFile)
@ -706,6 +715,7 @@ function run () {
}
}
}
}
var previousInput = ''
var saveTimeout = null
@ -758,10 +768,6 @@ function run () {
}
})
compiler.event.register('compilationStarted', this, function () {
editor.clearAnnotations()
})
function startdebugging (txHash) {
self.event.trigger('debuggingRequested', [])
transactionDebugger.debug(txHash)

@ -31,8 +31,8 @@ module.exports = {
return ethJSABI.methodID(funABI.name, types)
},
sortAbiFunction: function (contract) {
var abi = contract.abi.sort(function (a, b) {
sortAbiFunction: function (contractabi) {
var abi = contractabi.sort(function (a, b) {
if (a.name > b.name) {
return -1
} else {

@ -338,10 +338,22 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
function loadFromAddress (appAPI) {
noInstancesText.style.display = 'none'
var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)
var contract = appAPI.getContract(contractNames.children[contractNames.selectedIndex].innerHTML)
var address = atAddressButtonInput.value
if (/.(.abi)$/.exec(appAPI.currentFile())) {
modalDialogCustom.confirm(null, 'Do you really want to interact with ' + address + ' using the current ABI definition ?', () => {
var abi
try {
abi = JSON.parse(appAPI.editorContent())
} catch (e) {
return modalDialogCustom.alert('Failed to parse the current file as JSON ABI.')
}
instanceContainer.appendChild(appAPI.udapp().renderInstanceFromABI(abi, address, address))
})
} else {
var contract = appAPI.getContract(contractNames.children[contractNames.selectedIndex].innerHTML)
instanceContainer.appendChild(appAPI.udapp().renderInstance(contract.object, address, selectContractNames.value))
}
}
// GET NAMES OF ALL THE CONTRACTS
function getContractNames (success, data) {

@ -9,13 +9,19 @@ module.exports = {
var len = data.length
return data.slice(0, 5) + '...' + data.slice(len - 5, len)
},
createNonClashingName (path, fileProvider) {
createNonClashingName (name, fileProvider) {
var counter = ''
if (path.endsWith('.sol')) path = path.substring(0, path.lastIndexOf('.sol'))
while (fileProvider.exists(path + counter + '.sol')) {
var ext = 'sol'
var reg = /(.*)\.([^.]+)/g
var split = reg.exec(name)
if (split) {
name = split[1]
ext = split[2]
}
while (fileProvider.exists(name + counter + '.' + ext)) {
counter = (counter | 0) + 1
}
return path + counter + '.sol'
return name + counter + '.' + ext
},
checkSpecialChars (name) {
return name.match(/[/:*?"<>\\'|]/) != null

@ -277,11 +277,16 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
}
}
UniversalDApp.prototype.renderInstance = function (contract, address, contractName) {
var abi = txHelper.sortAbiFunction(contract.abi)
return this.renderInstanceFromABI(abi, address, contractName)
}
// TODO this function was named before "appendChild".
// this will render an instance: contract name, contract address, and all the public functions
// basically this has to be called for the "atAddress" (line 393) and when a contract creation succeed
// this returns a DOM element
UniversalDApp.prototype.renderInstance = function (contract, address, contractName) {
UniversalDApp.prototype.renderInstanceFromABI = function (contractABI, address, contractName) {
var self = this
function remove () { instance.remove() }
@ -305,7 +310,7 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa
$(instance).toggleClass(`${css.hidesub}`)
}
var abi = txHelper.sortAbiFunction(contract)
var abi = txHelper.sortAbiFunction(contractABI)
instance.appendChild(title)

@ -10,7 +10,8 @@ module.exports = {
testFunction,
checkDebug,
goToVMtraceStep,
useFilter
useFilter,
addInstance
}
function getCompiledContracts (browser, compiled, callback) {
@ -97,6 +98,19 @@ function testFunction (fnFullName, txHash, log, expectedInput, expectedReturn, e
return this
}
function addInstance (browser, address, done) {
browser.setValue('.ataddressinput', address, function () {
browser.click('div[class^="atAddress"]')
.perform((client) => {
browser.execute(function () {
document.querySelector('#modal-footer-ok').click()
}, [], function (result) {
done()
})
})
})
}
function addFile (browser, name, content, done) {
browser.click('.newFile')
.perform((client, done) => {

@ -54,10 +54,23 @@ function runTests (browser, testData) {
.perform(function (client, done) {
contractHelper.checkDebug(browser, 'soliditylocals', localsCheck, () => {
done()
})
})
.click('.runView')
.click('div[class^="udappClose"]')
.perform(function (client, done) {
contractHelper.addFile(client, 'ballot.abi', { content: ballotABI }, () => {
contractHelper.addInstance(client, '0x692a70d2e424a56d2c6c27aa97d1a86395877b3a', () => {
browser.testFunction('delegate - transact (not payable)', '0x7a9ebc90614274b7eb6b072f9bba7825e588cf88ae00598cfdbc4c215b88433e',
'[vm] from:0xca3...a733c, to:Ballot.delegate(address) 0x692...77b3a, value:0 wei, data:0x5c1...4d2db, 0 logs, hash:0x7a9...8433e',
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null).perform(() => {
done()
browser.end()
})
})
})
})
})
}
var localsCheck = {
@ -117,3 +130,5 @@ var stateCheck = {
'constant': false
}
}
var ballotABI = '[{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"_winningProposal","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"toVoter","type":"address"}],"name":"giveRightToVote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"toProposal","type":"uint8"}],"name":"vote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]'

Loading…
Cancel
Save