Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
ed187886
Unverified
Commit
ed187886
authored
Dec 06, 2017
by
yann300
Committed by
GitHub
Dec 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #700 from ethereum/atAddressAbi
use "At address" when the content is abi
parents
43cf513e
56681d25
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
30 deletions
+88
-30
app.js
src/app.js
+24
-18
txHelper.js
src/app/execution/txHelper.js
+2
-2
run-tab.js
src/app/tabs/run-tab.js
+14
-2
helper.js
src/lib/helper.js
+10
-4
universal-dapp.js
src/universal-dapp.js
+7
-2
contracts.js
test-browser/helpers/contracts.js
+15
-1
ballot.js
test-browser/tests/ballot.js
+16
-1
No files found.
src/app.js
View file @
ed187886
...
...
@@ -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,22 +693,26 @@ function run () {
if
(
transactionDebugger
.
isActive
)
return
fileManager
.
saveCurrentFile
()
editor
.
clearAnnotations
()
var
currentFile
=
config
.
get
(
'currentFile'
)
if
(
currentFile
)
{
var
target
=
currentFile
var
sources
=
{}
var
provider
=
fileManager
.
fileProviderOf
(
currentFile
)
if
(
provider
)
{
provider
.
get
(
target
,
(
error
,
content
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
}
else
{
sources
[
target
]
=
{
content
}
compiler
.
compile
(
sources
,
target
)
}
})
}
else
{
console
.
log
(
'cannot compile '
+
currentFile
+
'. Does not belong to any explorer'
)
if
(
/.
(
.sol
)
$/
.
exec
(
currentFile
))
{
// only compile *.sol file.
var
target
=
currentFile
var
sources
=
{}
var
provider
=
fileManager
.
fileProviderOf
(
currentFile
)
if
(
provider
)
{
provider
.
get
(
target
,
(
error
,
content
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
}
else
{
sources
[
target
]
=
{
content
}
compiler
.
compile
(
sources
,
target
)
}
})
}
else
{
console
.
log
(
'cannot compile '
+
currentFile
+
'. Does not belong to any explorer'
)
}
}
}
}
...
...
@@ -758,10 +768,6 @@ function run () {
}
})
compiler
.
event
.
register
(
'compilationStarted'
,
this
,
function
()
{
editor
.
clearAnnotations
()
})
function
startdebugging
(
txHash
)
{
self
.
event
.
trigger
(
'debuggingRequested'
,
[])
transactionDebugger
.
debug
(
txHash
)
...
...
src/app/execution/txHelper.js
View file @
ed187886
...
...
@@ -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
(
contract
abi
)
{
var
abi
=
contractabi
.
sort
(
function
(
a
,
b
)
{
if
(
a
.
name
>
b
.
name
)
{
return
-
1
}
else
{
...
...
src/app/tabs/run-tab.js
View file @
ed187886
...
...
@@ -338,9 +338,21 @@ 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
instanceContainer
.
appendChild
(
appAPI
.
udapp
().
renderInstance
(
contract
.
object
,
address
,
selectContractNames
.
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
...
...
src/lib/helper.js
View file @
ed187886
...
...
@@ -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
...
...
src/universal-dapp.js
View file @
ed187886
...
...
@@ -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
.
renderInstance
FromABI
=
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
(
contract
ABI
)
instance
.
appendChild
(
title
)
...
...
test-browser/helpers/contracts.js
View file @
ed187886
...
...
@@ -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
)
=>
{
...
...
test-browser/tests/ballot.js
View file @
ed187886
...
...
@@ -54,7 +54,20 @@ function runTests (browser, testData) {
.
perform
(
function
(
client
,
done
)
{
contractHelper
.
checkDebug
(
browser
,
'soliditylocals'
,
localsCheck
,
()
=>
{
done
()
browser
.
end
()
})
})
.
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
()
})
})
})
})
})
...
...
@@ -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"}]'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment