Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
if EOSN linked account is sender - override as funder
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Nov 7, 2023
1 parent 330d9e3 commit d5aae21
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
29 changes: 29 additions & 0 deletions include/eosn.login/login.eosn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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`
*
Expand Down
12 changes: 6 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
5 changes: 3 additions & 2 deletions src/notifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
Expand Down

0 comments on commit d5aae21

Please sign in to comment.