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
9fbe6965
Unverified
Commit
9fbe6965
authored
Jun 21, 2018
by
Iuri Matias
Committed by
GitHub
Jun 21, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11 from ethereum/yann300-patch-2
Fix Deploy Libraries
parents
085fd579
026a297f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
33 deletions
+29
-33
deployer.js
src/deployer.js
+29
-33
No files found.
src/deployer.js
View file @
9fbe6965
var
async
=
require
(
'async'
)
// TODO: replace this with remix's own deployer code
var
remixLib
=
require
(
'remix-lib'
)
function
deployAll
(
compileResult
,
web3
,
callback
)
{
let
compiledObject
=
{}
...
...
@@ -30,6 +29,7 @@ function deployAll (compileResult, web3, callback) {
compiledObject
[
className
].
code
=
code
compiledObject
[
className
].
filename
=
filename
compiledObject
[
className
].
className
=
className
compiledObject
[
className
].
raw
=
contract
if
(
contractFile
.
indexOf
(
'_test.sol'
)
>=
0
)
{
compiledObject
[
className
].
isTest
=
true
...
...
@@ -53,35 +53,7 @@ function deployAll (compileResult, web3, callback) {
next
(
null
,
contractsToDeploy
)
},
function
deployContracts
(
contractsToDeploy
,
next
)
{
async
.
eachOfLimit
(
contractsToDeploy
,
1
,
function
(
contractName
,
index
,
nextEach
)
{
let
contract
=
compiledObject
[
contractName
]
if
(
!
contract
)
{
console
.
error
(
'Contract not found: '
+
contractName
)
return
nextEach
(
new
Error
(
'Contract not found: '
+
contractName
))
}
let
contractObject
=
new
web3
.
eth
.
Contract
(
contract
.
abi
)
let
contractCode
=
'0x'
+
contract
.
code
// TODO: temporary code, and terrible if the contracts are not in order...
for
(
let
name
in
compiledObject
)
{
let
contractObj
=
compiledObject
[
name
]
let
linkReference
=
'__'
+
contractObj
.
filename
+
':'
+
contractObj
.
className
let
toReplace
=
linkReference
+
'_'
.
repeat
(
40
-
linkReference
.
length
)
if
(
contractCode
.
indexOf
(
linkReference
)
<
0
)
{
continue
}
if
(
!
contractObj
.
deployedAddress
)
{
throw
new
Error
(
'linking not found for '
+
name
+
' when deploying '
+
contractName
)
}
contractCode
=
contractCode
.
replace
(
new
RegExp
(
toReplace
,
'g'
),
contractObj
.
deployedAddress
.
slice
(
2
))
}
let
deployObject
=
contractObject
.
deploy
({
arguments
:
[],
data
:
contractCode
})
var
deployRunner
=
(
deployObject
,
contractObject
,
contractName
,
callback
)
=>
{
deployObject
.
estimateGas
().
then
((
gasValue
)
=>
{
deployObject
.
send
({
from
:
accounts
[
0
],
...
...
@@ -94,12 +66,36 @@ function deployAll (compileResult, web3, callback) {
contracts
[
contractName
]
=
contractObject
nextEach
()
callback
(
null
,
{
result
:
{
createdAddress
:
receipt
.
contractAddress
}
})
// TODO this will only work with JavaScriptV VM
}).
on
(
'error'
,
function
(
err
)
{
console
.
dir
(
err
)
nextEach
(
err
)
callback
(
err
)
})
})
}
async
.
eachOfLimit
(
contractsToDeploy
,
1
,
function
(
contractName
,
index
,
nextEach
)
{
let
contract
=
compiledObject
[
contractName
]
let
encodeDataFinalCallback
=
(
error
,
contractDeployData
)
=>
{
if
(
error
)
return
nextEach
(
error
)
let
contractObject
=
new
web3
.
eth
.
Contract
(
contract
.
abi
)
let
deployObject
=
contractObject
.
deploy
({
arguments
:
[],
data
:
'0x'
+
contractDeployData
.
dataHex
})
deployRunner
(
deployObject
,
contractObject
,
contractName
,
(
error
)
=>
{
nextEach
(
error
)
})
}
let
encodeDataStepCallback
=
(
msg
)
=>
{
console
.
dir
(
msg
)
}
let
encodeDataDeployLibraryCallback
=
(
libData
,
callback
)
=>
{
let
abi
=
compiledObject
[
libData
.
data
.
contractName
].
abi
let
code
=
compiledObject
[
libData
.
data
.
contractName
].
code
let
libraryObject
=
new
web3
.
eth
.
Contract
(
abi
)
let
deployObject
=
libraryObject
.
deploy
({
arguments
:
[],
data
:
'0x'
+
code
})
deployRunner
(
deployObject
,
libraryObject
,
libData
.
data
.
contractName
,
callback
)
}
let
funAbi
=
null
// no need to set the abi for encoding the constructor
let
params
=
''
// we suppose that the test contract does not have any param in the constructor
remixLib
.
execution
.
txFormat
.
encodeConstructorCallAndDeployLibraries
(
contractName
,
contract
.
raw
,
compileResult
,
params
,
funAbi
,
encodeDataFinalCallback
,
encodeDataStepCallback
,
encodeDataDeployLibraryCallback
)
},
function
()
{
next
(
null
,
contracts
)
})
...
...
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