From c02e3e7ab8f9bb785694c839a8923450b6bbb7c3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 16 Jul 2017 13:31:40 -0400 Subject: [PATCH] treat library as dependencies for contract deployment --- lib/contracts/contracts.js | 9 ++++++++- test_app/app/contracts/test.sol | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 97c67b87..e58d788a 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -138,8 +138,15 @@ class ContractsManager { for (className in self.contracts) { contract = self.contracts[className]; - if (contract.args === []) continue; + // look in code for dependencies + let libMatches = (contract.code.match(/\:(.*?)(?=_)/g) || []); + for (let match of libMatches) { + self.contractDependencies[className] = self.contractDependencies[className] || []; + self.contractDependencies[className].push(match.substr(1)); + } + // look in arguments for dependencies + if (contract.args === []) continue; let ref = contract.args; for (let j = 0; j < ref.length; j++) { let arg = ref[j]; diff --git a/test_app/app/contracts/test.sol b/test_app/app/contracts/test.sol index 2618d93d..da76aa29 100644 --- a/test_app/app/contracts/test.sol +++ b/test_app/app/contracts/test.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.11; -library AMyLib { +library ZAMyLib { function add(uint _a, uint _b) returns (uint _c) { return _a + _b; @@ -11,7 +11,7 @@ library AMyLib { contract Test { function testAdd() constant returns (uint _result) { - return AMyLib.add(1, 2); + return ZAMyLib.add(1, 2); } }