Skip to content

Commit

Permalink
added global slice ctx_address1
Browse files Browse the repository at this point in the history
  • Loading branch information
fabcotech committed Jul 24, 2024
1 parent 6d3195a commit 82b893e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions contracts/pingpong2.fc
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ int equal_slices(slice a, slice b) asm "SDEQ";

;; storage variables
global cell ctx_str;
global cell ctx_address1;

() load_data() impure {
var ds = get_data().begin_parse();
ctx_str = ds~load_ref();
ctx_address1 = ds~load_ref();
ds.end_parse();
}

() save_data() impure {
set_data(
begin_cell()
.store_ref(ctx_str)
.store_ref(ctx_address1)
.end_cell()
);
}
Expand All @@ -26,13 +29,22 @@ global cell ctx_str;
}
slice cs = in_msg_full.begin_parse();
cs~skip_bits(4);
slice sender_address = cs~load_msg_addr();
~dump(sender_address);
var sender_address = cs~load_msg_addr();

load_data();
slice current = ctx_str.begin_parse();
slice ping = begin_cell().store_slice("ping").end_cell().begin_parse();

~strdump("sender_address");
~dump(sender_address);
~strdump("ctx_address1");
~dump(ctx_address1.begin_parse());
if (equal_slices(sender_address, ctx_address1.begin_parse()) == -1) {
~strdump("sender_address and ctx_address1 are equal");
} else {
~strdump("sender_address and ctx_address1 are not equal");
}

if (equal_slices(current,ping) == -1) {
cell c = begin_cell().store_slice("pong").end_cell();
ctx_str = c;
Expand Down

0 comments on commit 82b893e

Please sign in to comment.