AntelopeIO / cdt

Contract Development Toolkit (CDT) is a suite of tools to facilitate C/C++ development of contracts for Antelope blockchains
Other
28 stars 31 forks source link

ABI contains table of other namespace when compiling with 4.0.0 #204

Closed jeisses closed 1 year ago

jeisses commented 1 year ago

Some of my smart contracts that work fine with 3.1.0 generate an invalid ABI when compiling with 4.0.0

After some searching, I noticed that the ABIs generated with 4.0.0 contain a table definition from an other namespace.

Minimal example, test.cpp:

#include <eosio/eosio.hpp>
#include <eosio/singleton.hpp>

using namespace eosio;

namespace other {
  struct config { name standard = name("test"); };
  typedef singleton <name("config"), config> configt;
};

class [[eosio::contract("test")]] test : public eosio::contract {
public:
  using contract::contract;

  [[eosio::action]]
  void init() {
  }
};

When compiling this with 3.1.0 the following ABI is generated, which is what I expect:

{
    "____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
    "version": "eosio::abi/1.2",
    "types": [],
    "structs": [
        {
            "name": "init",
            "base": "",
            "fields": []
        }
    ],
    "actions": [
        {
            "name": "init",
            "type": "init",
            "ricardian_contract": ""
        }
    ],
    "tables": [],
    "ricardian_clauses": [],
    "variants": [],
    "action_results": []
}

The ABI from 4.0.0:

{
    "____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
    "version": "eosio::abi/1.2",
    "types": [],
    "structs": [
        {
            "name": "init",
            "base": "",
            "fields": []
        }
    ],
    "actions": [
        {
            "name": "init",
            "type": "init",
            "ricardian_contract": ""
        }
    ],
    "tables": [
        {
            "name": "config",
            "type": "config",
            "index_type": "i64",
            "key_names": [],
            "key_types": []
        }
    ],
    "ricardian_clauses": [],
    "variants": [],
    "action_results": []
}

It incorrectly contains the config table which refers to an undefined config struct. Also strange is that, if the other namespace contains multiple table definitions, only one seems to be added the the ABI.

Not sure how/why this happens, but wanted to check if this is an issue with cdt or my compilation

heifner commented 1 year ago

Possibly fixed by https://github.com/AntelopeIO/cdt/pull/201

dimas1185 commented 1 year ago

@jeisses fixed by #201