Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singletons without structs do not generate tables in the ABI #155

Closed
nsjames opened this issue Apr 25, 2023 · 3 comments · Fixed by #178
Closed

Singletons without structs do not generate tables in the ABI #155

nsjames opened this issue Apr 25, 2023 · 3 comments · Fixed by #178
Assignees
Labels
actionable bug Something isn't working 👍 lgtm

Comments

@nsjames
Copy link
Contributor

nsjames commented Apr 25, 2023

It seems that unless you use a struct within a singleton it does not generate tables:[] in the ABI.

Doing something like this in the code leads to an empty tables array.

using _owners = singleton<"owners"_n, name>;

abi output:

"tables": [],
"ricardian_clauses": [],
"variants": [],

However, if you do something like this, then the table shows up.

TABLE test {
   uint64_t test;
};
using _test = singleton<"test"_n, test>;

abi output:

"tables": [
        {
            "name": "test",
            "type": "test",
            "index_type": "i64",
            "key_names": [],
            "key_types": []
        }
    ],
"ricardian_clauses": [],
"variants": [],
@nsjames
Copy link
Contributor Author

nsjames commented Apr 25, 2023

A little more information.

The _owners table with the name as row type is valid for usage within the contract, and also works externally if I manually specify the table in the ABI.

For instance, adding this to the tables array:

{
  "name": "owners",
  "type": "name",
  "index_type": "i64",
  "key_names": [],
  "key_types": []
}

@stephenpdeos stephenpdeos added bug Something isn't working and removed enhancement New feature or request labels Apr 25, 2023
@dimas1185
Copy link
Contributor

dimas1185 commented May 9, 2023

currently eosio_abigen_visitor::VisitDecl takes T from singleton<Singletone, T> to create a table type but it supposed to be singleton<Singletone, T>::row.
Fix is to change the type T -> singleton<Singletone, T>::row in abigen.add_table. However in that case we change cases where T was a table making it a table inside a table because of the definition row { T value; uint64_t primary_key() {} }. So what is generic solution? Do we want singleton<Singletone, T>::row for non-POD type and T for POD type?

@dimas1185 dimas1185 moved this from Todo to In Progress in Team Backlog May 11, 2023
@dimas1185
Copy link
Contributor

final solution is just to add table in the way @nsjames suggested above for _owners example. see #178

@BenjaminGormanPMP BenjaminGormanPMP moved this from In Progress to Awaiting Review in Team Backlog May 16, 2023
@github-project-automation github-project-automation bot moved this from Awaiting Review to Done in Team Backlog May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable bug Something isn't working 👍 lgtm
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants