Skip to content

Commit

Permalink
Merge pull request #6 from AntelopeIO/abigen-ricardian-fix
Browse files Browse the repository at this point in the history
Bugfix for ricardian contracts being generated
  • Loading branch information
Bucky Kittinger authored Aug 17, 2022
2 parents 7e9a52a + ccf2297 commit 5a36e48
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 5 deletions.
28 changes: 28 additions & 0 deletions tests/toolchain/abigen-pass/ricardian_contract_test.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "test",
"base": "",
"fields": []
}
],
"actions": [
{
"name": "test",
"type": "test",
"ricardian_contract": "---\nspec-version: 0.0.2\ntitle: test\nsummary: This method does nothing on purpose.\nicon:\n---\n\nThis test checks ricardian contract was generated succesfully."
}
],
"tables": [],
"ricardian_clauses": [
{
"id": "Disclaimer",
"body": "This test checks ricardian contract was generated succesfully."
}
],
"variants": [],
"action_results": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1 class="clause">Disclaimer</h1>

This test checks ricardian contract was generated succesfully.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1 class="contract">test</h1>
---
spec-version: 0.0.2
title: test
summary: This method does nothing on purpose.
icon:
---

This test checks ricardian contract was generated succesfully.
12 changes: 12 additions & 0 deletions tests/toolchain/abigen-pass/ricardian_contract_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <eosio/eosio.hpp>

using namespace eosio;

class [[eosio::contract]] ricardian_contract_test : public contract {
public:
using contract::contract;

[[eosio::action]]
void test() {
}
};
10 changes: 10 additions & 0 deletions tests/toolchain/abigen-pass/ricardian_contract_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tests" : [
{
"compile_flags" : ["-R={cwd}"],
"expected" : {
"abi-file" : "ricardian_contract_test.abi"
}
}
]
}
8 changes: 4 additions & 4 deletions tools/include/eosio/abigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,8 @@ namespace eosio { namespace cdt {

virtual bool VisitCXXMethodDecl(clang::CXXMethodDecl* decl) {
if (!has_added_clauses) {
ag.add_clauses(parse_clauses());
ag.add_contracts(parse_contracts());
ag.add_clauses(ag.parse_clauses());
ag.add_contracts(ag.parse_contracts());
has_added_clauses = true;
}

Expand All @@ -784,8 +784,8 @@ namespace eosio { namespace cdt {
}
virtual bool VisitCXXRecordDecl(clang::CXXRecordDecl* decl) {
if (!has_added_clauses) {
ag.add_clauses(parse_clauses());
ag.add_contracts(parse_contracts());
ag.add_clauses(ag.parse_clauses());
ag.add_contracts(ag.parse_contracts());
has_added_clauses = true;
}
if ((decl->isEosioAction() || decl->isEosioTable()) && ag.is_eosio_contract(decl, ag.get_contract_name())) {
Expand Down
3 changes: 2 additions & 1 deletion tools/toolchain-tester/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _run(self, cdt_cpp: str, args: List[str]):
def run(self):
cf = self.test_json.get("compile_flags")
args = cf if cf else []
args = [arg.replace("{cwd}", self.test_suite.directory) for arg in args]

cdt_cpp = os.path.join(self.test_suite.cdt_path, "cdt-cpp")
self._run(cdt_cpp, args)
Expand Down Expand Up @@ -202,5 +203,5 @@ def _run(self, cdt_cpp, args):
command.extend(args)
res = subprocess.run(command, capture_output=True)
self.handle_test_result(res, expected_pass=False)

return res

0 comments on commit 5a36e48

Please sign in to comment.