identity_test.cpp 1.2 KB
Newer Older
1 2
#include <eosiolib/action.h>
#include <eosiolib/contract.hpp>
3
#include <eosiolib/dispatcher.hpp>
4
#include <identity/interface.hpp>
5 6 7 8 9

namespace identity_test {
   
   using eosio::action_meta;
   using eosio::singleton;
10 11
   using std::string;
   using std::vector;
12

13
   class contract : public eosio::contract {
14
      public:
15
         static constexpr uint64_t code = N(identitytest);
16
         typedef singleton<N(result), uint64_t> result_table;
17

18 19
         using eosio::contract::contract;

A
Anton Perkov 已提交
20
         void getowner( const uint64_t identity ) {
21 22 23
            identity::interface iface( N(identity) );
            account_name owner = iface.get_owner_for_identity(current_receiver(), identity);
            result_table( code, 0 ).set( owner, code ); //use scope = 0 for simplicity
24 25
         }

26 27 28 29
         void getidentity( const account_name account ) {
            identity::interface iface( N(identity) );
            identity::identity_name idnt = iface.get_identity_for_account(current_receiver(), account);
            result_table( code, 0 ).set(idnt, code ); //use scope = 0 for simplicity
30 31 32 33 34
         }
   };

} /// namespace identity

A
Anton Perkov 已提交
35
EOSIO_ABI( identity_test::contract, (getowner)(getidentity) );