#include "../";
#pragma version >=1.0.0;

global int k_const;
const int k = 1;

() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {
    slice cs = in_msg_full.begin_parse();
    int flags = cs~load_uint(0x4_1_0);

    if ((flags & 1) == true) { ;; ignore all bounced messages
        return ();
    }

    slice sender_address = cs~load_msg_addr();

    {-
    {-
    test - is test
    -}
    -}

    ;; Send message
    var message = begin_cell()
        .store_uint(0x18, 6)
        .store_slice(sender_address)
        .store_coins(0)
        .store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1)
        .store_slice("Hello, world!"s)
        .end_cell();

    send_raw_message(message, 64);

    ;; Update counter
    var cs = get_data().begin_parse();
    var counter = data~load_uint(32);

    store_data(
        begin_cell()
            .store_uint(counter + 1, 32)
        .end_cell()
    );
}

() recv_external(slice in_msg) impure {
    throw(0xffff);
}

int counter() method_id {
    var data = get_data().begin_parse();
    return data~load_uint(32);
}