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
2d91cce3
Commit
2d91cce3
authored
Jun 08, 2016
by
chriseth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #43 from redsquirrel/lib-linking-in-web3
Deploying and linking libraries in Web3 context
parents
ad67d93f
7669354e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
27 deletions
+31
-27
universal-dapp.js
src/universal-dapp.js
+31
-27
No files found.
src/universal-dapp.js
View file @
2d91cce3
...
@@ -424,18 +424,14 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -424,18 +424,14 @@ UniversalDApp.prototype.getCallButton = function (args) {
if
(
isConstructor
)
{
if
(
isConstructor
)
{
if
(
args
.
bytecode
.
indexOf
(
'_'
)
>=
0
)
{
if
(
args
.
bytecode
.
indexOf
(
'_'
)
>=
0
)
{
replaceOutput
(
$result
,
$
(
'<span>Deploying and linking required libraries...</span>'
));
replaceOutput
(
$result
,
$
(
'<span>Deploying and linking required libraries...</span>'
));
if
(
self
.
options
.
vm
)
{
self
.
linkBytecode
(
args
.
contractName
,
function
(
err
,
bytecode
)
{
self
.
linkBytecode
(
args
.
contractName
,
function
(
err
,
bytecode
)
{
if
(
err
)
{
if
(
err
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'Error deploying required libraries: '
+
err
));
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'Error deploying required libraries: '
+
err
));
}
else
{
}
else
{
args
.
bytecode
=
bytecode
;
args
.
bytecode
=
bytecode
;
handleCallButtonClick
(
ev
,
$result
);
handleCallButtonClick
(
ev
,
$result
);
}
}
});
});
}
else
{
replaceOutput
(
$result
,
$
(
'<span>Contract needs to be linked to a library, this is only supported in the JavaScript VM for now.</span>'
));
}
return
;
return
;
}
else
{
}
else
{
data
=
args
.
bytecode
+
data
;
data
=
args
.
bytecode
+
data
;
...
@@ -487,19 +483,6 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -487,19 +483,6 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
else
if
(
args
.
abi
.
constant
&&
!
isConstructor
)
{
}
else
if
(
args
.
abi
.
constant
&&
!
isConstructor
)
{
replaceOutput
(
$result
,
getReturnOutput
(
result
));
replaceOutput
(
$result
,
getReturnOutput
(
result
));
}
else
{
}
else
{
function
tryTillResponse
(
txhash
,
done
)
{
this
.
web3
.
eth
.
getTransactionReceipt
(
result
,
testResult
);
function
testResult
(
err
,
address
)
{
if
(
!
err
&&
!
address
)
{
setTimeout
(
function
()
{
tryTillResponse
(
txhash
,
done
);
},
500
);
}
else
{
done
(
err
,
address
);
}
}
}
tryTillResponse
(
result
,
function
(
err
,
result
)
{
tryTillResponse
(
result
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
err
).
addClass
(
'error'
));
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
err
).
addClass
(
'error'
));
...
@@ -584,8 +567,16 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) {
...
@@ -584,8 +567,16 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) {
if
(
err
)
{
if
(
err
)
{
return
cb
(
err
);
return
cb
(
err
);
}
}
self
.
getContractByName
(
contractName
).
address
=
result
.
createdAddress
;
if
(
self
.
options
.
vm
)
{
cb
(
err
,
result
.
createdAddress
);
self
.
getContractByName
(
contractName
).
address
=
result
.
createdAddress
;
cb
(
err
,
result
.
createdAddress
);
}
else
{
tryTillResponse
(
result
,
function
(
err
,
finalResult
)
{
if
(
err
)
return
cb
(
err
);
self
.
getContractByName
(
contractName
).
address
=
finalResult
.
contractAddress
;
cb
(
null
,
finalResult
.
contractAddress
);
});
}
});
});
}
}
};
};
...
@@ -664,4 +655,17 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
...
@@ -664,4 +655,17 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
}
}
};
};
function
tryTillResponse
(
txhash
,
done
)
{
this
.
web3
.
eth
.
getTransactionReceipt
(
txhash
,
testResult
);
function
testResult
(
err
,
address
)
{
if
(
!
err
&&
!
address
)
{
setTimeout
(
function
()
{
tryTillResponse
(
txhash
,
done
);
},
500
);
}
else
{
done
(
err
,
address
);
}
}
}
module
.
exports
=
UniversalDApp
;
module
.
exports
=
UniversalDApp
;
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