diff --git a/include/eosn.login/login.eosn.hpp b/include/eosn.login/login.eosn.hpp index 2fa84c8..c3397fc 100644 --- a/include/eosn.login/login.eosn.hpp +++ b/include/eosn.login/login.eosn.hpp @@ -448,6 +448,35 @@ class [[eosio::contract("login.eosn")]] login : public eosio::contract { return false; } + /** + * ## STATIC `is_user_id_exists` + * + * Returns true/false if user ID exists + * + * ### params + * + * - `{name} user_id` - user ID + * - `{name} [login_contract="login.eosn"]` - (optional) EOSN login contract + * + * ### returns + * + * - `{bool}` - [true/false] if user ID exists + * + * ### example + * + * ```c++ + * const name user_id = "123.eosn"_n; + * const bool exists = eosn::login::is_user_id_exists( user_id ); + * //=> true + * ``` + */ + static bool is_user_id_exists( const name user_id, const name login_contract ) + { + login::users_table _users( login_contract, login_contract.value ); + auto users = _users.find( user_id.value ); + return users != _users.end(); + } + /** * ## STATIC `require_auth_user_id` * diff --git a/scripts/build.sh b/scripts/build.sh index 0e6a532..c03babc 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,7 +1,7 @@ #!/bin/bash -# unlock wallet -cleos wallet unlock --password $(cat ~/eosio-wallet/.pass) +# # unlock wallet +# cleos wallet unlock --password $(cat ~/eosio-wallet/.pass) # build @@ -38,7 +38,7 @@ if [ ! -f "./include/eosn.login/login.eosn.wasm" ]; then $CDT ./include/eosn.login/login.eosn.cpp -I include -o include/eosn.login/login.eosn.wasm --no-missing-ricardian-clause fi -if [ ! -f "./include/oracle.defi/oracle.defi.wasm" ]; then - echo "compiling... [oracle.defi]" - $CDT ./include/oracle.defi/oracle.defi.cpp -I include -o include/oracle.defi/oracle.defi.wasm --no-missing-ricardian-clause -fi +# if [ ! -f "./include/oracle.defi/oracle.defi.wasm" ]; then +# echo "compiling... [oracle.defi]" +# $CDT ./include/oracle.defi/oracle.defi.cpp -I include -o include/oracle.defi/oracle.defi.wasm --no-missing-ricardian-clause +# fi diff --git a/src/notifiers.cpp b/src/notifiers.cpp index 86617ee..564b8ea 100644 --- a/src/notifiers.cpp +++ b/src/notifiers.cpp @@ -8,7 +8,7 @@ void pomelo::on_transfer( const name from, const name to, const asset quantity, if ( to != get_self() || from == "eosio.ram"_n ) return; // parse memo - const auto [ bounty_id, user_id ] = parse_memo(memo); + auto [ bounty_id, user_id ] = parse_memo(memo); check(bounty_id.value, ERROR_INVALID_MEMO); // handle token transfer @@ -29,7 +29,8 @@ void pomelo::deposit_bounty( const name bounty_id, const name user_id, const nam const auto token = get_token( ext_quantity ); const int64_t min_amount = token.min_amount; const int64_t max_amount = token.max_amount; - const name funder_user_id = user_id.value ? user_id : bounty->author_user_id; //if no user id specified - assume it came from the author + name funder_user_id = user_id.value ? user_id : bounty->author_user_id; // if no user id specified - assume it came from the author + if ( eosn::login::is_user_id_exists(from, get_self() ) ) funder_user_id = from; // if EOSN linked account is sender - override as funder // TO-DO: bounty can only deposit when state == "pending/open/started" check( STATUS_DEPOSIT_TYPES.find(bounty->status) != STATUS_DEPOSIT_TYPES.end(), "pomelo::deposit_bounty: bounty not available for funding");