ton-blockchain / token-contract

Fungible, Non-Fungible, Semi-Fungible Tokens Smart Contracts
Other
299 stars 158 forks source link

Revert "Jettons and nft test added" #52

Open abooodabdlaa opened 1 month ago

abooodabdlaa commented 1 month ago

Reverts ton-blockchain/token-contract#13

Whistler2407 commented 3 weeks ago

;; Jackpot.ton

include "imports/stdlib.fc";

(slice) load_data() inline { var ds = get_data().begin_parse(); return( ds~load_msg_addr() ;; owner_address ); }

() save_data(slice owner_address) impure inline { set_data( begin_cell() .store_slice(owner_address) .end_cell() ); }

() send_transaction(slice address, int value) impure inline { var msg = begin_cell() .store_uint(0x10, 6) .store_slice(address) .store_coins(value) .store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) .store_uint(0, 32) .store_slice("Transfer from Jackpot.ton Coinflip!") .end_cell();

send_raw_message(msg, 0);

}

() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {

if (in_msg_body.slice_empty?()) { ;; ignore empty messages
    return ();
}

slice cs = in_msg_full.begin_parse();
int flags = cs~load_uint(4);

if(flags & 1) { ;; Skip bounce
    return();
}

slice sender_address = cs~load_msg_addr();
int op = in_msg_body~load_uint(32);

if(op == 777) { ;; Coin flip!

    throw_unless(62, msg_value >= 1000000000);

    int flipper_balance = my_balance - msg_value;
    int max_flip = (flipper_balance / 100) * 10; ;; 10%
    throw_unless(69, max_flip >= msg_value);

    randomize_lt();

    int random_number = rand(100); ;; 0 - 99

    if(random_number > 50) { ;; win logic
        send_transaction(sender_address, msg_value * 2);
    }

    return();
}

(slice owner_address) = load_data();

throw_unless(71, equal_slices(sender_address, owner_address));

if(op == 3) { ;; Change owner_address
    slice new_owner_address = in_msg_body~load_msg_addr();
    save_data(new_owner_address);
    return();
}

if(op == 4) { ;; Collect fees
    int collect_value = in_msg_body~load_coins();
    throw_unless(70, (my_balance - collect_value > 10000000000)); ;; 10 TON
    send_transaction(owner_address, collect_value);
    return();
}

}