Skip to content

Commit

Permalink
order
Browse files Browse the repository at this point in the history
  • Loading branch information
Skydev0h committed Dec 26, 2023
1 parent 7ec7d55 commit b86789b
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions contracts/task3.fc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "imports/stdlib.fc";

cell get_storage() {
cell get_storage() inline {
return get_data().begin_parse().preload_ref();
}

cell wrap_storage(int version_id, cell storage) {
cell wrap_storage(int version_id, cell storage) inline {
;; add additional data required for versioning in this cell
return begin_cell()
.store_uint(version_id, 32)
Expand Down Expand Up @@ -37,20 +37,23 @@ cell migrate_one(cell old_storage) { return old_storage; }
() recv_internal(int msg_value, int balance, cell in_msg_full, slice in_msg_body) impure {
if (in_msg_body.slice_bits() < 32) { return(); } ;; deploy / ordinary
int expected_version = in_msg_body~load_uint(32);

if (expected_version == 0) {
set_data(begin_cell()
.store_uint(1, 32)
.store_ref(get_data())
.end_cell()
);
return();
}

cell expected_code = in_msg_body~load_maybe_ref();
cell migrations = in_msg_body~load_dict();
cell payload = in_msg_body~load_ref();

if (expected_version == 0) {
if (expected_code.null?()) {
if (migrations.dict_empty?()) {
set_data(begin_cell()
.store_uint(1, 32)
.store_ref(get_data())
.end_cell()
);
return ();
}
}
}

slice ds = get_data().begin_parse();
int version = ds.preload_uint(32);
cell storage = ds.preload_ref();
Expand Down

0 comments on commit b86789b

Please sign in to comment.