Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix invitatioin #3146

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/gas_faucet/sources/gas_faucet.move
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,22 @@ module gas_faucet::gas_faucet {

/// Anyone can call this function to help the claimer claim the faucet
public entry fun claim(faucet_obj: &mut Object<RGasFaucet>, claimer: address, utxo_ids: vector<ObjectID>){
Self::do_claim(faucet_obj, claimer, utxo_ids);
}

/// Claim the faucet for the claimer, return true if it is the first time to claim
public fun do_claim(faucet_obj: &mut Object<RGasFaucet>, claimer: address, utxo_ids: vector<ObjectID>): bool{
let claim_rgas_amount = Self::check_claim(faucet_obj, claimer, utxo_ids);
let faucet = object::borrow_mut(faucet_obj);
let rgas_coin = coin_store::withdraw(&mut faucet.rgas_store, claim_rgas_amount);
account_coin_store::deposit<RGas>(claimer, rgas_coin);
let total_claim_amount = table::borrow_mut_with_default(&mut faucet.claim_records, claimer, 0u256);
let first_claim = *total_claim_amount == 0;
*total_claim_amount = *total_claim_amount + claim_rgas_amount;
first_claim
}




public entry fun deposit_rgas_coin(
account: &signer,
faucet_obj: &mut Object<RGasFaucet>,
Expand Down
16 changes: 10 additions & 6 deletions apps/invitation_record/sources/invitation.move
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module invitation_record::invitation {
use rooch_framework::gas_coin::RGas;
use rooch_framework::coin_store::CoinStore;
use rooch_framework::coin_store;
use gas_faucet::gas_faucet::{RGasFaucet, claim};
use gas_faucet::gas_faucet::{RGasFaucet, do_claim};
use moveos_std::table;
use moveos_std::object;
use app_admin::admin::AdminCap;
Expand Down Expand Up @@ -153,11 +153,17 @@ module invitation_record::invitation {
let full_message = encode_full_message(MessagePrefix, message);
verify_btc_signature(bitcoin_address, public_key, signature, full_message);
let claimer = bitcoin_address::to_rooch_address(&bitcoin_address);
assert!(inviter != claimer, ErrorCannotInviteOneself);
//assert!(inviter != claimer, ErrorCannotInviteOneself);
let invitation_conf = object::borrow_mut(invitation_obj);
assert!(invitation_conf.is_open, ErrorFaucetNotOpen);
if (inviter == @rooch_framework){
claim(faucet_obj, claimer, utxo_ids);
//If the inviter is the rooch_framework or the claimer, we do not need to record the invitation relationship
if (inviter == @rooch_framework || inviter == claimer){
do_claim(faucet_obj, claimer, utxo_ids);
return
};
let first_claim = do_claim(faucet_obj, claimer, utxo_ids);
//If the claimer has claimed the faucet, we do not need to record the invitation relationship
if (!first_claim){
return
};
if (!table::contains(&invitation_conf.invitation_records, inviter)) {
Expand All @@ -181,8 +187,6 @@ module invitation_record::invitation {
user_invitation_records.remaining_luckey_ticket = user_invitation_records.remaining_luckey_ticket + 1u64;
let rgas_coin = coin_store::withdraw(&mut invitation_conf.rgas_store, invitation_conf.unit_invitation_amount);
account_coin_store::deposit<RGas>(inviter, rgas_coin);

claim(faucet_obj, claimer, utxo_ids);
}

public entry fun claim_from_twitter(
Expand Down
Loading