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
7669354e
Commit
7669354e
authored
Jun 06, 2016
by
Dave Hoover
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deploying and linking libraries in Web3 context
parent
f738864d
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 @
7669354e
...
...
@@ -418,18 +418,14 @@ UniversalDApp.prototype.getCallButton = function (args) {
if
(
isConstructor
)
{
if
(
args
.
bytecode
.
indexOf
(
'_'
)
>=
0
)
{
replaceOutput
(
$result
,
$
(
'<span>Deploying and linking required libraries...</span>'
));
if
(
self
.
options
.
vm
)
{
self
.
linkBytecode
(
args
.
contractName
,
function
(
err
,
bytecode
)
{
if
(
err
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'Error deploying required libraries: '
+
err
));
}
else
{
args
.
bytecode
=
bytecode
;
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>'
));
}
self
.
linkBytecode
(
args
.
contractName
,
function
(
err
,
bytecode
)
{
if
(
err
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'Error deploying required libraries: '
+
err
));
}
else
{
args
.
bytecode
=
bytecode
;
handleCallButtonClick
(
ev
,
$result
);
}
});
return
;
}
else
{
data
=
args
.
bytecode
+
data
;
...
...
@@ -481,19 +477,6 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
else
if
(
args
.
abi
.
constant
&&
!
isConstructor
)
{
replaceOutput
(
$result
,
getReturnOutput
(
result
));
}
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
)
{
if
(
err
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
err
).
addClass
(
'error'
));
...
...
@@ -578,8 +561,16 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) {
if
(
err
)
{
return
cb
(
err
);
}
self
.
getContractByName
(
contractName
).
address
=
result
.
createdAddress
;
cb
(
err
,
result
.
createdAddress
);
if
(
self
.
options
.
vm
)
{
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
);
});
}
});
}
};
...
...
@@ -658,4 +649,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
;
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