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

"Invalid nesting" error when trying to use an optional vector in ABI #26

Open
michael-drygola opened this issue Apr 10, 2024 · 0 comments

Comments

@michael-drygola
Copy link

I've got an EOS smart contract which uses std::optional<std::vector<eosio::name>> as a type of one of its fields. When compiled with AntelopeIO CDT v4.0.1, it produces an ABI which seems to be valid and works fine when deployed to blockchain. However, the abieos lib fails to parse the ABI and throws an "Invalid nesting" error.

Here is a minimum reproducible code to illustrate the problem:

#include <abieos.h>
#include <iostream>

int main( int argc, char** argv ) {
    const char *bad_abi = R"(
    {
      "version": "eosio::abi/1.2",
      "types": [{
          "new_type_name": "B_vector_name_E",
          "type": "name[]"
        }
      ],
      "structs": [{
          "name": "actionname",
          "base": "",
          "fields": [{
              "name": "opt_list",
              "type": "B_vector_name_E?"
            }
          ]
        }
      ],
      "actions": [{
          "name": "actionname",
          "type": "actionname",
          "ricardian_contract": ""
        }
      ],
      "ricardian_clauses": [],
      "error_messages": [],
      "abi_extensions": [],
      "variants": [],
      "action_results": []
    }
    )";

    auto context = abieos_create ();
    if (abieos_set_abi (context, 1, bad_abi)) {
        std::cout << "OK";
    } else {
        std::cout << abieos_get_error (context); // getting "Invalid nesting" here
    }

    return 0;
}

Considering this ABI is valid, would be nice to add support of such nested structures to the lib :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant