infinitex-tech / Oasis

EOSIO Blockchain Development Tutorial
MIT License
40 stars 12 forks source link

Tutorial Part 2. error: no matching constructor for initalization of 'eosio::action' #2

Closed ajose01 closed 6 years ago

ajose01 commented 6 years ago

First off, as others have said... the tutorial is A++. Thanks 🙏 . I've tried to debug this on my own w/o much luck. I may just be overlooking something obvious, since I don't see others running into this issue. When trying to generate the ABI I hit this:

/Users/angeljose/Apps/eosapps/Oasis/contracts/Marketplace/Marketplace.cpp:16:5: error: no matching constructor for initialization of 'eosio::action'
    action(vector<permission_level>(), N(anorak), N(transfer), make_tuple(buyer, _self, productPrice, string(""))).send();
    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/eosiolib/action.hpp:148:7: note: candidate constructor not viable: no known conversion from 'vector<eosio::permission_level>' to
      'const eosio::permission_level' for 1st argument
      action( const permission_level& auth, account_name a, action_name n, const Action& value )
      ^
/usr/local/include/eosiolib/action.hpp:113:7: note: candidate constructor template not viable: requires 2 arguments, but 4 were provided
      action( vector<permission_level>&& auth, const Action& value ) {
      ^
/usr/local/include/eosiolib/action.hpp:125:7: note: candidate constructor template not viable: requires 2 arguments, but 4 were provided
      action( const permission_level& auth, const Action& value )
      ^
/usr/local/include/eosiolib/action.hpp:137:7: note: candidate constructor template not viable: requires single argument 'value', but 4 arguments were provided
      action( const Action& value ) {
      ^
/usr/local/include/eosiolib/action.hpp:100:11: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 4 were provided
   struct action {
          ^
/usr/local/include/eosiolib/action.hpp:100:11: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 4 were provided
/usr/local/include/eosiolib/action.hpp:106:7: note: candidate constructor not viable: requires 0 arguments, but 4 were provided
      action() = default;
      ^
/Users/angeljose/Apps/eosapps/Oasis/contracts/Marketplace/Marketplace.cpp:18:5: error: no matching constructor for initialization of 'eosio::action'
    action(vector<permission_level>(), N(anorak), N(additem), make_tuple(buyer,
    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/eosiolib/action.hpp:148:7: note: candidate constructor not viable: no known conversion from 'vector<eosio::permission_level>' to
      'const eosio::permission_level' for 1st argument
      action( const permission_level& auth, account_name a, action_name n, const Action& value )
      ^
/usr/local/include/eosiolib/action.hpp:113:7: note: candidate constructor template not viable: requires 2 arguments, but 4 were provided
      action( vector<permission_level>&& auth, const Action& value ) {
      ^
/usr/local/include/eosiolib/action.hpp:125:7: note: candidate constructor template not viable: requires 2 arguments, but 4 were provided
      action( const permission_level& auth, const Action& value )
      ^
/usr/local/include/eosiolib/action.hpp:137:7: note: candidate constructor template not viable: requires single argument 'value', but 4 arguments were provided
      action( const Action& value ) {
      ^
/usr/local/include/eosiolib/action.hpp:100:11: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 4 were provided
   struct action {
          ^
/usr/local/include/eosiolib/action.hpp:100:11: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 4 were provided
/usr/local/include/eosiolib/action.hpp:106:7: note: candidate constructor not viable: requires 0 arguments, but 4 were provided
      action() = default;

Marketplace.hpp:

#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
#include <string>

Marketplace.cpp:

#include "Marketplace.hpp"
#include <eosiolib/asset.hpp>

namespace Oasis {
  void Marketplace::buy(account_name buyer, uint64_t productId) {
    productIndex products(_self, _self);

    auto iterator = products.find(productId);
    eosio_assert(iterator != products.end(), "The product was not found");

    auto product = products.get(productId);
    eosio_assert(product.quantity > 0, "The product is out of stock");

    asset productPrice = asset(product.price, string_to_symbol(4, "OAS"));

    action(vector<permission_level>(), N(anorak), N(transfer), make_tuple(buyer, _self, productPrice, string(""))).send();

    action(vector<permission_level>(), N(anorak), N(additem), make_tuple(buyer,
      product.product_id,
      product.name,
      product.power,
      product.health,
      product.ability,
      product.level_up 
    )).send();

    update(buyer, product.product_id, -1);
  };

Thanks for any clues.

johnX9 commented 6 years ago

Hi ajose01! Do you have the eosiolib inside the contracts folder? action.hpp is placed there.

ajose01 commented 6 years ago

Thanks for the reply. I do have it in there, and can confirm that action.hpp is in there as well. It might be an EOS version thing?

For example... I get the same error even when trying to process an ABI from a gitclone of this repo.

➜  InfLabs git:(master) cd EOS-dApp-development-tutorial-part-2
➜  EOS-dApp-development-tutorial-part-2 git:(master) ls
CMakeLists.txt CMakeModules   README.md      contracts      externals      libraries
➜  EOS-dApp-development-tutorial-part-2 git:(master) cd contracts
➜  contracts git:(master) ls
CMakeLists.txt Marketplace    Players        eosiolib       libc++         musl
➜  contracts git:(master) cd Marketplace
➜  Marketplace git:(master) ls
CMakeLists.txt  Marketplace.abi Marketplace.cpp Marketplace.hpp
➜  Marketplace git:(master) eosiocpp -g M.abi Marketplace.cpp
2018-08-09T19:38:42.440 thread-0   abi_generator.hpp:68          ricardian_contracts  ] Warning, no ricardian clauses found for Marketplace

2018-08-09T19:38:42.443 thread-0   abi_generator.hpp:75          ricardian_contracts  ] Warning, no ricardian contract found for buy

2018-08-09T19:38:42.443 thread-0   abi_generator.hpp:75          ricardian_contracts  ] Warning, no ricardian contract found for getbyid

2018-08-09T19:38:42.443 thread-0   abi_generator.hpp:75          ricardian_contracts  ] Warning, no ricardian contract found for add

2018-08-09T19:38:42.443 thread-0   abi_generator.hpp:75          ricardian_contracts  ] Warning, no ricardian contract found for update

2018-08-09T19:38:42.443 thread-0   abi_generator.hpp:75          ricardian_contracts  ] Warning, no ricardian contract found for remove

/Users/angeljose/Apps/eosapps/InfLabs/EOS-dApp-development-tutorial-part-2/contracts/Marketplace/Marketplace.cpp:17:9: error: no
      matching constructor for initialization of 'eosio::action'
        action(vector<permission_level>(), N(anorak), N(transfer), make_tuple(buyer, _self, productPrice, string(""))).send();
        ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
johnX9 commented 6 years ago

I cloned the repo and I was able to generate the Marketplace.abi. Which version of EOSIO you're using? Can you try to rebuild the EOSIO with clean installation?