Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Order ABI correctly in multi-contract files #45

Merged
merged 2 commits into from
Mar 7, 2018
Merged

Conversation

cgewecke
Copy link
Contributor

@cgewecke cgewecke commented Feb 25, 2018

Addresses truffle 812

While processing the AST to identify ContractDefinitions, we have to make sure a given definition node matches the contract name. Solc produces an AST that lays out all the contracts in a file adjacently but only one of these belongs to the contract in question.

Re-factored the tests so that we have examples of single contract files, multi-contract files and inheritance from an imported file.

@cgewecke cgewecke changed the title [WIP] Order ABI correctly in multi-contract files Order ABI correctly in multi-contract files Feb 26, 2018
@cgewecke cgewecke requested a review from gnidan March 6, 2018 18:25

it("orders the complex ABI", function(){
var expectedOrder = ['LogB', 'LogA', 'LogD', 'LogC', 'theFirst', 'second', 'andThird'];
var sources = {};
Copy link
Contributor Author

@cgewecke cgewecke Mar 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little confusing. . . i.e not sure events are contributing to clarity of this test.

Copy link
Contributor

@gnidan gnidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the additional comments (also the tests!)

// AST can have multiple contract definitions, make sure we have the
// one that matches our contract
if (definition.name !== "ContractDefinition" ||
definition.attributes.name !== contract.contract_name){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe contract.contractName cause snake case is deprecated in truffle-contract-schema

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch and agree but will revisit in a separate PR because contract_name all over the place in this file and need to investigate the full implications of upgrading here.

@cgewecke cgewecke merged commit f65f8c1 into develop Mar 7, 2018
@cgewecke cgewecke deleted the fix/abi-disorder branch March 7, 2018 21:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants