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
fde4ee1e
Unverified
Commit
fde4ee1e
authored
Feb 28, 2018
by
yann300
Committed by
GitHub
Feb 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #709 from ethereum/fixDeployLibrary
Fix deploy library
parents
084e7907
b550b007
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
8 deletions
+115
-8
nightwatch.js
remix-debugger/nightwatch.js
+2
-2
package.json
remix-debugger/package.json
+1
-1
package.json
remix-lib/package.json
+1
-0
txFormat.js
remix-lib/src/execution/txFormat.js
+42
-4
txFormat.js
remix-lib/test/txFormat.js
+69
-1
No files found.
remix-debugger/nightwatch.js
View file @
fde4ee1e
...
@@ -62,8 +62,8 @@ module.exports = {
...
@@ -62,8 +62,8 @@ module.exports = {
'desiredCapabilities'
:
{
'desiredCapabilities'
:
{
'browserName'
:
'safari'
,
'browserName'
:
'safari'
,
'javascriptEnabled'
:
true
,
'javascriptEnabled'
:
true
,
'platform'
:
'OS X 10.1
0
'
,
'platform'
:
'OS X 10.1
1
'
,
'version'
:
'
8
.0'
,
'version'
:
'
10
.0'
,
'acceptSslCerts'
:
true
,
'acceptSslCerts'
:
true
,
'build'
:
'build-'
+
TRAVIS_JOB_NUMBER
,
'build'
:
'build-'
+
TRAVIS_JOB_NUMBER
,
'tunnel-identifier'
:
'remix_tests_'
+
TRAVIS_JOB_NUMBER
'tunnel-identifier'
:
'remix_tests_'
+
TRAVIS_JOB_NUMBER
...
...
remix-debugger/package.json
View file @
fde4ee1e
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
"nightwatch_remote_chrome"
:
"nightwatch --config nightwatch.js --env chrome"
,
"nightwatch_remote_chrome"
:
"nightwatch --config nightwatch.js --env chrome"
,
"nightwatch_remote_firefox"
:
"nightwatch --config nightwatch.js --env default"
,
"nightwatch_remote_firefox"
:
"nightwatch --config nightwatch.js --env default"
,
"nightwatch_remote_ie"
:
"nightwatch --config nightwatch.js --env ie"
,
"nightwatch_remote_ie"
:
"nightwatch --config nightwatch.js --env ie"
,
"nightwatch_remote_parallel"
:
"nightwatch --config nightwatch.js --env
ie,
safari,chrome,default"
,
"nightwatch_remote_parallel"
:
"nightwatch --config nightwatch.js --env safari,chrome,default"
,
"nightwatch_remote_safari"
:
"nightwatch --config nightwatch.js --env safari"
,
"nightwatch_remote_safari"
:
"nightwatch --config nightwatch.js --env safari"
,
"onchange"
:
"onchange build/app.js -- npm run lint"
,
"onchange"
:
"onchange build/app.js -- npm run lint"
,
"selenium"
:
"selenium-standalone start"
,
"selenium"
:
"selenium-standalone start"
,
...
...
remix-lib/package.json
View file @
fde4ee1e
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
],
],
"main"
:
"./index.js"
,
"main"
:
"./index.js"
,
"dependencies"
:
{
"dependencies"
:
{
"async"
:
"^2.1.2"
,
"babel-preset-es2015"
:
"^6.24.0"
,
"babel-preset-es2015"
:
"^6.24.0"
,
"babel-plugin-transform-object-assign"
:
"^6.22.0"
,
"babel-plugin-transform-object-assign"
:
"^6.22.0"
,
"babel-eslint"
:
"^7.1.1"
,
"babel-eslint"
:
"^7.1.1"
,
...
...
remix-lib/src/execution/txFormat.js
View file @
fde4ee1e
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
ethJSABI
=
require
(
'ethereumjs-abi'
)
var
ethJSABI
=
require
(
'ethereumjs-abi'
)
var
helper
=
require
(
'./txHelper'
)
var
helper
=
require
(
'./txHelper'
)
var
executionContext
=
require
(
'./execution-context'
)
var
executionContext
=
require
(
'./execution-context'
)
var
asyncJS
=
require
(
'async'
)
module
.
exports
=
{
module
.
exports
=
{
...
@@ -99,10 +100,37 @@ module.exports = {
...
@@ -99,10 +100,37 @@ module.exports = {
atAddress
:
function
()
{},
atAddress
:
function
()
{},
linkBytecode
:
function
(
contract
,
contracts
,
udapp
,
callback
,
callbackStep
)
{
linkBytecodeStandard
:
function
(
contract
,
contracts
,
udapp
,
callback
,
callbackStep
)
{
if
(
contract
.
evm
.
bytecode
.
object
.
indexOf
(
'_'
)
<
0
)
{
asyncJS
.
eachOfSeries
(
contract
.
evm
.
bytecode
.
linkReferences
,
(
libs
,
file
,
cbFile
)
=>
{
return
callback
(
null
,
contract
.
evm
.
bytecode
.
object
)
asyncJS
.
eachOfSeries
(
contract
.
evm
.
bytecode
.
linkReferences
[
file
],
(
libRef
,
libName
,
cbLibDeployed
)
=>
{
var
library
=
contracts
[
file
][
libName
]
if
(
library
)
{
this
.
deployLibrary
(
file
+
':'
+
libName
,
libName
,
library
,
contracts
,
udapp
,
(
error
,
address
)
=>
{
if
(
error
)
{
return
cbLibDeployed
(
error
)
}
var
hexAddress
=
address
.
toString
(
'hex'
)
if
(
hexAddress
.
slice
(
0
,
2
)
===
'0x'
)
{
hexAddress
=
hexAddress
.
slice
(
2
)
}
contract
.
evm
.
bytecode
.
object
=
this
.
linkLibraryStandard
(
libName
,
hexAddress
,
contract
)
cbLibDeployed
()
},
callbackStep
)
}
else
{
cbLibDeployed
(
'Cannot find compilation data of library '
+
libName
)
}
},
(
error
)
=>
{
cbFile
(
error
)
})
},
(
error
)
=>
{
if
(
error
)
{
callbackStep
(
error
)
}
}
callback
(
error
,
contract
.
evm
.
bytecode
.
object
)
})
},
linkBytecodeLegacy
:
function
(
contract
,
contracts
,
udapp
,
callback
,
callbackStep
)
{
var
libraryRefMatch
=
contract
.
evm
.
bytecode
.
object
.
match
(
/__
([^
_
]{1,36})
__/
)
var
libraryRefMatch
=
contract
.
evm
.
bytecode
.
object
.
match
(
/__
([^
_
]{1,36})
__/
)
if
(
!
libraryRefMatch
)
{
if
(
!
libraryRefMatch
)
{
return
callback
(
'Invalid bytecode format.'
)
return
callback
(
'Invalid bytecode format.'
)
...
@@ -129,12 +157,22 @@ module.exports = {
...
@@ -129,12 +157,22 @@ module.exports = {
if
(
hexAddress
.
slice
(
0
,
2
)
===
'0x'
)
{
if
(
hexAddress
.
slice
(
0
,
2
)
===
'0x'
)
{
hexAddress
=
hexAddress
.
slice
(
2
)
hexAddress
=
hexAddress
.
slice
(
2
)
}
}
contract
.
evm
.
bytecode
.
object
=
this
.
linkLibraryStandard
(
libraryShortName
,
hexAddress
,
contract
)
contract
.
evm
.
bytecode
.
object
=
this
.
linkLibrary
(
libraryName
,
hexAddress
,
contract
.
evm
.
bytecode
.
object
)
contract
.
evm
.
bytecode
.
object
=
this
.
linkLibrary
(
libraryName
,
hexAddress
,
contract
.
evm
.
bytecode
.
object
)
this
.
linkBytecode
(
contract
,
contracts
,
udapp
,
callback
,
callbackStep
)
this
.
linkBytecode
(
contract
,
contracts
,
udapp
,
callback
,
callbackStep
)
},
callbackStep
)
},
callbackStep
)
},
},
linkBytecode
:
function
(
contract
,
contracts
,
udapp
,
callback
,
callbackStep
)
{
if
(
contract
.
evm
.
bytecode
.
object
.
indexOf
(
'_'
)
<
0
)
{
return
callback
(
null
,
contract
.
evm
.
bytecode
.
object
)
}
if
(
contract
.
evm
.
bytecode
.
linkReferences
&&
Object
.
keys
(
contract
.
evm
.
bytecode
.
linkReferences
).
length
)
{
this
.
linkBytecodeStandard
(
contract
,
contracts
,
udapp
,
callback
,
callbackStep
)
}
else
{
this
.
linkBytecodeLegacy
(
contract
,
contracts
,
udapp
,
callback
,
callbackStep
)
}
},
deployLibrary
:
function
(
libraryName
,
libraryShortName
,
library
,
contracts
,
udapp
,
callback
,
callbackStep
)
{
deployLibrary
:
function
(
libraryName
,
libraryShortName
,
library
,
contracts
,
udapp
,
callback
,
callbackStep
)
{
var
address
=
library
.
address
var
address
=
library
.
address
if
(
address
)
{
if
(
address
)
{
...
...
remix-lib/test/txFormat.js
View file @
fde4ee1e
...
@@ -3,9 +3,10 @@ var tape = require('tape')
...
@@ -3,9 +3,10 @@ var tape = require('tape')
var
txFormat
=
require
(
'../src/execution/txFormat'
)
var
txFormat
=
require
(
'../src/execution/txFormat'
)
var
compiler
=
require
(
'solc'
)
var
compiler
=
require
(
'solc'
)
var
compilerInput
=
require
(
'../src/helpers/compilerHelper'
).
compilerInput
var
compilerInput
=
require
(
'../src/helpers/compilerHelper'
).
compilerInput
var
executionContext
=
require
(
'../src/execution/execution-context'
)
var
context
var
context
tape
(
'ContractParameters - (TxFormat.buildData)'
,
function
(
t
)
{
tape
(
'ContractParameters - (TxFormat.buildData)
- format input parameters
'
,
function
(
t
)
{
var
output
=
compiler
.
compileStandardWrapper
(
compilerInput
(
uintContract
))
var
output
=
compiler
.
compileStandardWrapper
(
compilerInput
(
uintContract
))
output
=
JSON
.
parse
(
output
)
output
=
JSON
.
parse
(
output
)
var
contract
=
output
.
contracts
[
'test.sol'
][
'uintContractTest'
]
var
contract
=
output
.
contracts
[
'test.sol'
][
'uintContractTest'
]
...
@@ -30,6 +31,51 @@ function testWithInput (st, params, expected) {
...
@@ -30,6 +31,51 @@ function testWithInput (st, params, expected) {
},
()
=>
{})
},
()
=>
{})
}
}
tape
(
'ContractParameters - (TxFormat.buildData) - link Libraries'
,
function
(
t
)
{
executionContext
.
setContext
(
'vm'
)
var
output
=
compiler
.
compileStandardWrapper
(
compilerInput
(
deploySimpleLib
))
output
=
JSON
.
parse
(
output
)
var
contract
=
output
.
contracts
[
'test.sol'
][
'testContractLinkLibrary'
]
var
fakeDeployedContracts
=
{
lib1
:
'0xf7a10e525d4b168f45f74db1b61f63d3e7619e11'
,
lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2
:
'0xf7a10e525d4b168f45f74db1b61f63d3e7619e33'
,
testContractLinkLibrary
:
'0xf7a10e525d4b168f45f74db1b61f63d3e7619e22'
}
var
udapp
=
{
runTx
:
(
param
,
callback
)
=>
{
callback
(
null
,
{
result
:
{
createdAddress
:
fakeDeployedContracts
[
param
.
data
.
contractName
]
}
})
}
}
// fake
context
=
{
output
,
contract
,
udapp
}
t
.
test
(
'(TxFormat.buildData and link library (standard way))'
,
function
(
st
)
{
st
.
plan
(
6
)
testLinkLibrary
(
st
,
fakeDeployedContracts
)
})
})
function
testLinkLibrary
(
st
,
fakeDeployedContracts
)
{
var
deployMsg
=
[
'creation of library test.sol:lib1 pending...'
,
'creation of library test.sol:lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2 pending...'
]
txFormat
.
buildData
(
'testContractLinkLibrary'
,
context
.
contract
,
context
.
output
.
contracts
,
true
,
context
.
contract
.
abi
[
0
],
''
,
context
.
udapp
,
(
error
,
data
)
=>
{
if
(
error
)
{
return
st
.
fails
(
error
)
}
console
.
log
(
data
)
var
linkedbyteCode
=
data
.
dataHex
var
libReference
=
context
.
contract
.
evm
.
bytecode
.
linkReferences
[
'test.sol'
][
'lib1'
]
st
.
equal
(
linkedbyteCode
.
substr
(
2
*
libReference
[
0
].
start
,
40
),
fakeDeployedContracts
[
'lib1'
].
replace
(
'0x'
,
''
))
st
.
equal
(
linkedbyteCode
.
substr
(
2
*
libReference
[
1
].
start
,
40
),
fakeDeployedContracts
[
'lib1'
].
replace
(
'0x'
,
''
))
libReference
=
context
.
contract
.
evm
.
bytecode
.
linkReferences
[
'test.sol'
][
'lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2'
]
st
.
equal
(
linkedbyteCode
.
substr
(
2
*
libReference
[
0
].
start
,
40
),
fakeDeployedContracts
[
'lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2'
].
replace
(
'0x'
,
''
))
st
.
equal
(
linkedbyteCode
.
substr
(
2
*
libReference
[
1
].
start
,
40
),
fakeDeployedContracts
[
'lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2'
].
replace
(
'0x'
,
''
))
},
(
msg
)
=>
{
st
.
equal
(
msg
,
deployMsg
[
0
])
deployMsg
.
shift
()
})
}
var
uintContract
=
`contract uintContractTest {
var
uintContract
=
`contract uintContractTest {
uint _tp;
uint _tp;
address _ap;
address _ap;
...
@@ -38,3 +84,25 @@ var uintContract = `contract uintContractTest {
...
@@ -38,3 +84,25 @@ var uintContract = `contract uintContractTest {
_ap = _a;
_ap = _a;
}
}
}`
}`
var
deploySimpleLib
=
`pragma solidity ^0.4.4;
library lib1 {
function getEmpty () {
}
}
library lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2 {
function getEmpty () {
}
}
contract testContractLinkLibrary {
function get () {
lib1.getEmpty();
lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2.getEmpty();
lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2_lib2.getEmpty();
lib1.getEmpty();
}
}`
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