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
026a297f
Commit
026a297f
authored
Jun 20, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Deploy Libraries
parent
085fd579
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 @
026a297f
var
async
=
require
(
'async'
)
var
async
=
require
(
'async'
)
var
remixLib
=
require
(
'remix-lib'
)
// TODO: replace this with remix's own deployer code
function
deployAll
(
compileResult
,
web3
,
callback
)
{
function
deployAll
(
compileResult
,
web3
,
callback
)
{
let
compiledObject
=
{}
let
compiledObject
=
{}
...
@@ -30,6 +29,7 @@ function deployAll (compileResult, web3, callback) {
...
@@ -30,6 +29,7 @@ function deployAll (compileResult, web3, callback) {
compiledObject
[
className
].
code
=
code
compiledObject
[
className
].
code
=
code
compiledObject
[
className
].
filename
=
filename
compiledObject
[
className
].
filename
=
filename
compiledObject
[
className
].
className
=
className
compiledObject
[
className
].
className
=
className
compiledObject
[
className
].
raw
=
contract
if
(
contractFile
.
indexOf
(
'_test.sol'
)
>=
0
)
{
if
(
contractFile
.
indexOf
(
'_test.sol'
)
>=
0
)
{
compiledObject
[
className
].
isTest
=
true
compiledObject
[
className
].
isTest
=
true
...
@@ -53,35 +53,7 @@ function deployAll (compileResult, web3, callback) {
...
@@ -53,35 +53,7 @@ function deployAll (compileResult, web3, callback) {
next
(
null
,
contractsToDeploy
)
next
(
null
,
contractsToDeploy
)
},
},
function
deployContracts
(
contractsToDeploy
,
next
)
{
function
deployContracts
(
contractsToDeploy
,
next
)
{
async
.
eachOfLimit
(
contractsToDeploy
,
1
,
function
(
contractName
,
index
,
nextEach
)
{
var
deployRunner
=
(
deployObject
,
contractObject
,
contractName
,
callback
)
=>
{
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
})
deployObject
.
estimateGas
().
then
((
gasValue
)
=>
{
deployObject
.
estimateGas
().
then
((
gasValue
)
=>
{
deployObject
.
send
({
deployObject
.
send
({
from
:
accounts
[
0
],
from
:
accounts
[
0
],
...
@@ -94,12 +66,36 @@ function deployAll (compileResult, web3, callback) {
...
@@ -94,12 +66,36 @@ function deployAll (compileResult, web3, callback) {
contracts
[
contractName
]
=
contractObject
contracts
[
contractName
]
=
contractObject
nextEach
()
callback
(
null
,
{
result
:
{
createdAddress
:
receipt
.
contractAddress
}
})
// TODO this will only work with JavaScriptV VM
}).
on
(
'error'
,
function
(
err
)
{
}).
on
(
'error'
,
function
(
err
)
{
console
.
dir
(
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
()
{
},
function
()
{
next
(
null
,
contracts
)
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