Merge pull request #202 from sc-forks/allow-interfaces

Allow interface contracts
pull/203/head
c-g-e-w-e-k-e- 7 years ago committed by GitHub
commit f15e0f1805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      lib/instrumentSolidity.js
  2. 4
      lib/parse.js
  3. 6
      test/cli/totallyPure.js
  4. 7
      test/sources/cli/Face.sol
  5. 10
      test/sources/cli/TotallyPure.sol
  6. 1
      test/util/mockTruffle.js

@ -40,7 +40,8 @@ module.exports = function instrumentSolidity(contractSource, fileName) {
ast = SolidityParser.parse(contract.preprocessed);
const contractStatement = ast.body.filter(node => (node.type === 'ContractStatement' ||
node.type === 'LibraryStatement'));
node.type === 'LibraryStatement' ||
node.type === 'InterfaceStatement'));
contract.contractName = contractStatement[0].name;
parse[ast.type](contract, ast);

@ -102,6 +102,10 @@ parse.IfStatement = function parseIfStatement(contract, expression) {
}
};
parse.InterfaceStatement = function parseInterfaceStatement(contract, expression) {
parse.ContractOrLibraryStatement(contract, expression);
};
parse.LibraryStatement = function parseLibraryStatement(contract, expression) {
parse.ContractOrLibraryStatement(contract, expression);
};

@ -74,4 +74,10 @@ contract('TotallyPure', accounts => {
const value = await instance.multiline(5, 7)
assert.equal(value.toNumber(), 99);
});
it('calls a method who signature is defined by an interface', async () => {
const instance = await TotallyPure.deployed();
await instance.cry();
});
});

@ -0,0 +1,7 @@
pragma experimental "v0.5.0";
//pragma solidity ^0.4.17;
interface Face {
function stare(uint a, uint b) external;
function cry() external;
}

@ -1,10 +1,11 @@
pragma experimental "v0.5.0";
//pragma solidity ^0.4.17;
import "./../assets/Face.sol";
import "./../assets/PureView.sol";
import "./../assets/CLibrary.sol";
contract TotallyPure is PureView {
contract TotallyPure is PureView, Face {
uint onehundred = 99;
function usesThem() {
@ -49,4 +50,11 @@ contract TotallyPure is PureView {
return onehundred;
}
function stare(uint a, uint b) external {
uint z = a + b;
}
function cry() external {
}
}

@ -167,6 +167,7 @@ module.exports.installLibraryTest = function installInheritanceTest(config) {
shell.cp('./test/cli/totallyPure.js', './mock/test/totallyPure.js');
shell.cp('./test/sources/cli/PureView.sol', './mock/assets/PureView.sol');
shell.cp('./test/sources/cli/CLibrary.sol', './mock/assets/CLibrary.sol');
shell.cp('./test/sources/cli/Face.sol', './mock/assets/Face.sol');
// Mock truffle.js
const trufflejs = `module.exports = {

Loading…
Cancel
Save