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
8a0697dc
Commit
8a0697dc
authored
Feb 05, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix linking issue
parent
a23965a2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
19 deletions
+60
-19
simple_storage_test.sol
examples/simple_storage_test.sol
+4
-4
tests.sol
sol/tests.sol
+8
-2
compiler.js
src/compiler.js
+5
-0
deployer.js
src/deployer.js
+43
-13
No files found.
examples/simple_storage_test.sol
View file @
8a0697dc
...
@@ -10,13 +10,13 @@ contract MyTest {
...
@@ -10,13 +10,13 @@ contract MyTest {
}
}
function initialValueShouldBe100() public constant returns (bool) {
function initialValueShouldBe100() public constant returns (bool) {
//
return Assert.equal(foo.get(), 100, "initial value is not correct");
return Assert.equal(foo.get(), 100, "initial value is not correct");
return foo.get() == 100;
//
return foo.get() == 100;
}
}
function initialValueShouldBe200() public constant returns (bool) {
function initialValueShouldBe200() public constant returns (bool) {
//
return Assert.equal(foo.get(), 200, "initial value is not correct");
return Assert.equal(foo.get(), 200, "initial value is not correct");
return foo.get() == 200;
//
return foo.get() == 200;
}
}
}
}
...
...
sol/tests.sol
View file @
8a0697dc
...
@@ -2,8 +2,14 @@ pragma solidity ^0.4.7;
...
@@ -2,8 +2,14 @@ pragma solidity ^0.4.7;
library Assert {
library Assert {
function equal(uint a, uint b, string text) {
event AssertionEvent(
//return a == b;
bool indexed passed,
string message
);
function equal(uint a, uint b, string message) public returns (bool result) {
result = (a == b);
AssertionEvent(result, message);
}
}
}
}
...
...
src/compiler.js
View file @
8a0697dc
...
@@ -36,6 +36,11 @@ function compileFileOrFiles (filename, isDirectory, cb) {
...
@@ -36,6 +36,11 @@ function compileFileOrFiles (filename, isDirectory, cb) {
compiler
.
compile
(
sources
,
filepath
)
compiler
.
compile
(
sources
,
filepath
)
}
}
],
function
(
err
,
result
)
{
],
function
(
err
,
result
)
{
let
errors
=
result
.
errors
.
filter
((
e
)
=>
e
.
type
===
'Error'
);
if
(
errors
.
length
>
0
)
{
console
.
dir
(
errors
);
return
cb
(
"errors compiling"
);
}
cb
(
err
,
result
.
contracts
)
cb
(
err
,
result
.
contracts
)
})
})
}
}
...
...
src/deployer.js
View file @
8a0697dc
...
@@ -30,12 +30,32 @@ function deployAll (compileResult, web3, callback) {
...
@@ -30,12 +30,32 @@ 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
if
(
contractFile
.
indexOf
(
"_test.sol"
)
>=
0
)
{
compiledObject
[
className
].
isTest
=
true
}
}
}
}
}
next
()
next
()
},
},
function
deployContracts
(
next
)
{
function
determineContractsToDeploy
(
next
)
{
async
.
eachOfLimit
(
compiledObject
,
1
,
function
(
contract
,
contractName
,
nextEach
)
{
let
contractsToDeploy
=
[
'Assert'
];
let
allContracts
=
Object
.
keys
(
compiledObject
);
for
(
let
contractName
of
allContracts
)
{
if
(
contractName
===
'Assert'
)
{
continue
;
}
if
(
compiledObject
[
contractName
].
isTest
)
{
contractsToDeploy
.
push
(
contractName
)
}
}
next
(
null
,
contractsToDeploy
);
},
function
deployContracts
(
contractsToDeploy
,
next
)
{
async
.
eachOfLimit
(
contractsToDeploy
,
1
,
function
(
contractName
,
index
,
nextEach
)
{
let
contract
=
compiledObject
[
contractName
];
console
.
dir
(
'deploying... '
+
contractName
);
let
contractObject
=
new
web3
.
eth
.
Contract
(
contract
.
abi
)
let
contractObject
=
new
web3
.
eth
.
Contract
(
contract
.
abi
)
let
contractCode
=
'0x'
+
contract
.
code
let
contractCode
=
'0x'
+
contract
.
code
...
@@ -54,22 +74,32 @@ function deployAll (compileResult, web3, callback) {
...
@@ -54,22 +74,32 @@ function deployAll (compileResult, web3, callback) {
throw
new
Error
(
'linking not found for '
+
name
+
' when deploying '
+
contractName
)
throw
new
Error
(
'linking not found for '
+
name
+
' when deploying '
+
contractName
)
}
}
contractCode
=
contractCode
.
replace
(
new
RegExp
(
toReplace
,
'g'
),
contractObj
.
deployedAddress
)
console
.
dir
(
"replacing "
+
toReplace
+
" with "
+
contractObj
.
deployedAddress
);
contractCode
=
contractCode
.
replace
(
new
RegExp
(
toReplace
,
'g'
),
contractObj
.
deployedAddress
.
slice
(
2
))
}
}
contractObject
.
deploy
({
arguments
:
[],
data
:
contractCode
}).
send
({
console
.
dir
(
contractCode
);
from
:
accounts
[
0
],
gas
:
4000
*
1000
let
deployObject
=
contractObject
.
deploy
({
arguments
:
[],
data
:
contractCode
});
}).
on
(
'receipt'
,
function
(
receipt
)
{
contractObject
.
options
.
address
=
receipt
.
contractAddress
contractObject
.
options
.
from
=
accounts
[
0
]
contractObject
.
options
.
gas
=
4000
*
1000
compiledObject
[
contractName
].
deployedAddress
=
receipt
.
contractAddress
contracts
[
contractName
]
=
contractObject
console
.
dir
(
"estimating gas..."
);
deployObject
.
estimateGas
().
then
((
gasValue
)
=>
{
console
.
dir
(
"gas value is "
+
gasValue
);
deployObject
.
send
({
from
:
accounts
[
0
],
gas
:
5000
*
1000
}).
on
(
'receipt'
,
function
(
receipt
)
{
contractObject
.
options
.
address
=
receipt
.
contractAddress
contractObject
.
options
.
from
=
accounts
[
0
]
contractObject
.
options
.
gas
=
5000
*
1000
compiledObject
[
contractName
].
deployedAddress
=
receipt
.
contractAddress
nextEach
()
contracts
[
contractName
]
=
contractObject
nextEach
()
})
})
})
},
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