I am working with a smart contract using eos.cdt v1.3.2. I have already attempted to refactor as much possible to keep up with the changes made in eos.cdt. Here is the contract:
#include <eosiolib/eosio.hpp>
#include <eosiolib/name.hpp>
using namespace eosio;
using namespace std;
class addressbook: contract {
struct address {
uint64_t account_name;
string first_name;
string last_name;
string street;
string city;
string state;
auto primary_key() const { return account_name; }
EOSLIB_SERIALIZE( address, (account_name)(first_name)(last_name)(street)(city)(state) )
};
public:
using contract::contract;
addressbook(name receiver, name code, datastream<const char*> ds):contract(receiver, code, ds) {}
typedef eosio::multi_index< "address"_n, address > address_index;
void myaction() {
address_index addresses(_code, _code.value); // code, scope
// add to table, first argument is account to bill for storage
addresses.emplace(_self, [&](auto& address) {
address.account_name = name("foo");
address.first_name = "Daniel";
address.last_name = "Larimer";
address.street = "1 EOS Way";
address.city = "Blacksburg";
address.state = "VA";
});
auto user = addresses.get(name("foo"));
eosio_assert(user.first_name == "Daniel", "Couldn't get him.");
}
}
EOSIO_ABI( addressbook, (myaction) )
When I attempt to compile from the command line I get these error messages:
get.cpp:34:33: error: no viable conversion from 'eosio::name' to 'uint64_t' (aka
'unsigned long long')
auto user = addresses.get(name("foo"));
^~~~~~~~~~~
/usr/local/eosio.cdt/bin/../include/eosiolib/name.hpp:131:17: note: candidate
function
constexpr operator raw()const { return raw(value); }
^
/usr/local/eosio.cdt/bin/../include/eosiolib/multi_index.hpp:1963:30: note:
passing argument to parameter 'primary' here
const T& get( uint64_t primary, const char* error_msg = "unable t...
^
get.cpp:38:26: error: C++ requires a type specifier for all declarations
EOSIO_ABI( addressbook, (myaction) )
^
get.cpp:38:37: error: expected function body after function declarator
EOSIO_ABI( addressbook, (myaction) )
^
get.cpp:27:32: error: assigning to 'uint64_t' (aka 'unsigned long long') from
incompatible type 'eosio::name'
address.account_name = name("foo");
^~~~~~~~~~~
/usr/local/eosio.cdt/bin/../include/eosiolib/multi_index.hpp:1691:13: note: in
instantiation of function template specialization
'addressbook::myaction()::(anonymous
class)::operator()<addressbook::address>' requested here
constructor( obj );
^
get.cpp:26:17: note: in instantiation of function template specialization
'eosio::multi_index<3626371193025593344,
addressbook::address>::emplace<(lambda at get.cpp:26:32)>' requested here
addresses.emplace(_self, [&](auto& address) {
^
4 errors generated.
I am mostly concerned with the error message that reads get.cpp:34:33: error: no viable conversion from 'eosio::name' to 'uint64_t' (aka 'unsigned long long') as this message has come about due to the changes in eos.cbt. However, there seems to be no solution on how to correct this. Has anyone been able to solve this issue?
Aucun commentaire:
Enregistrer un commentaire