-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add function to link binary with reference libraries in wrappers contract deployment #1988
Conversation
@tonykwok1992 could you please add here a solidity smart contract example for this case? |
Let me try and give the example, @gtebrean Assume you have a solidity library, like so... library SomeLib {
function someUsefulLibraryFunction() public pure returns (string memory) {
return "...";
}
} ...and a contract that makes use of this library, like so... import "./SomeLib.sol";
contract SomeContract {
function someFunction() public view returns (string memory message) {
message = SomeLib.someUsefulLibraryFunction();
}
} To be able to deploy In a migrate script for Truffle you might do it like this: const library = artifacts.require("SomeLib");
const contract = artifacts.require("SomeContract");
module.exports = async function (deployer, networks, accounts) {
await deployer.deploy(library);
const libraryInstance = await errors.deployed();
if (!libraryInstance.address) throw "Failed to deploy library";
/* this is not possible from web3j right now */
await deployer.link(errors, [contract]);
await deployer.deploy(contract);
contractInstance = await contract.deployed();
} |
Thanks for @cybernagl 's help to provide the solidity example. It is for the corresponding functionality in hardhat: also some inspiration from etherjs ethers-io/ethers.js#195 Currently this feature is not available in web3j Another thought on where to place this change is to have it in |
@tonykwok1992 The build is failing in local, these tests are failing -
Also plz rebase it to master and fix the failing tests, Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do a spotlessApply, rebase to master and Fix the failing tests
5918d8a
to
b9898fe
Compare
All done |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1988 +/- ##
============================================
- Coverage 69.22% 69.21% -0.01%
- Complexity 3116 3123 +7
============================================
Files 493 493
Lines 13093 13142 +49
Branches 1692 1695 +3
============================================
+ Hits 9063 9096 +33
- Misses 3538 3556 +18
+ Partials 492 490 -2 ☔ View full report in Codecov by Sentry. |
Made an enhancement to introduce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This reverts commit b9898fe.
cf93962
to
c495a39
Compare
rebased |
What does this PR do?
Add function to link binary with reference libraries in wrappers contract deployment
Where should the reviewer start?
All files
Why is it needed?
Currently there is no way to deploy contract that have library unlinked, Adding this functionality so that we can link the bytecode library placeholder with library address before deployment