|
|
|
@ -10,6 +10,31 @@
|
|
|
|
|
|
|
|
|
|
int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auction_start_duration = 604800; ;; 1 week = 60 * 60 * 24 * 7; in testnet 5 min |
|
|
|
|
const auction_end_duration = 3600; ;; 1 hour = 60 * 60; in testnet 1 min |
|
|
|
|
const auction_prolongation = 3600; ;; 1 hour = 60 * 60; in testnet 1 min |
|
|
|
|
|
|
|
|
|
;; MsgAddressInt max_bid_address |
|
|
|
|
;; Coins max_bid_amount |
|
|
|
|
;; int auction_end_time |
|
|
|
|
(slice, int, int) unpack_auction(cell auction) { |
|
|
|
|
if (cell_null?(auction)) { |
|
|
|
|
return (null(), 0, 0); |
|
|
|
|
} else { |
|
|
|
|
slice ds = auction.begin_parse(); |
|
|
|
|
return (ds~load_msg_addr(), ds~load_coins(), ds~load_uint(64)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cell pack_auction(slice max_bid_address, int max_bid_amount, int auction_end_time) { |
|
|
|
|
return begin_cell() |
|
|
|
|
.store_slice(max_bid_address) |
|
|
|
|
.store_coins(max_bid_amount) |
|
|
|
|
.store_uint(auction_end_time, 64) |
|
|
|
|
.end_cell(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
;; =============== storage ============================= |
|
|
|
|
;; |
|
|
|
|
;; Storage |
|
|
|
@ -110,7 +135,44 @@ slice calculate_nft_item_address(int wc, cell state_init) {
|
|
|
|
|
store_data(collection_content, nft_item_code, index, collection_address, new_owner_address, domain, auction, now()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
() recv_internal(int msg_value, cell in_msg, slice in_msg_body) impure { |
|
|
|
|
() recv_internal(int msg_value, cell in_msg_full, slice in_msg_body) impure { |
|
|
|
|
if (in_msg_body.slice_empty?()) { ;; bounce back empty messages |
|
|
|
|
throw(0xffff); |
|
|
|
|
} |
|
|
|
|
;; handle internal messages |
|
|
|
|
int op = in_msg_body.slice_empty?() ? 0 : in_msg_body~load_uint(32); |
|
|
|
|
slice cs = in_msg_full.begin_parse(); |
|
|
|
|
int flags = cs~load_uint(4); |
|
|
|
|
|
|
|
|
|
if (flags & 1) { ;; ignore all bounced messages |
|
|
|
|
return (); |
|
|
|
|
} |
|
|
|
|
slice sender_address = cs~load_msg_addr(); |
|
|
|
|
(cell content, cell item_code, int init?, int index, slice collection_address, slice owner_address, cell domain, cell auction, int last_fill_up_time) = load_data(); |
|
|
|
|
if (~ init?) { |
|
|
|
|
throw_unless(405, equal_slices(collection_address, sender_address)); |
|
|
|
|
slice from_address = in_msg_body~load_msg_addr(); |
|
|
|
|
cell domain = in_msg_body~load_ref(); |
|
|
|
|
|
|
|
|
|
cell content = begin_cell().store_uint(0, 8).store_dict(new_dict()).end_cell(); |
|
|
|
|
|
|
|
|
|
int seconds = now() - auction_start_time; |
|
|
|
|
int months = seconds / one_month; |
|
|
|
|
if (months > 12) { |
|
|
|
|
months = 12; |
|
|
|
|
} |
|
|
|
|
int duration = auction_start_duration - (auction_start_duration - auction_end_duration) * months / 12; |
|
|
|
|
|
|
|
|
|
int auction_end_time = now() + duration; |
|
|
|
|
store_data(content, item_code, index, collection_address, zero_address(), domain, pack_auction(from_address, msg_value, auction_end_time), now()); |
|
|
|
|
return (); |
|
|
|
|
} |
|
|
|
|
if (init? & equal_slices(collection_address, sender_address)) { ;; todo: add comments |
|
|
|
|
slice from_address = in_msg_body~load_msg_addr(); |
|
|
|
|
send_msg(from_address, 0, 0, cur_lt(), null(), 64); ;; carry all the remaining value of the inbound message |
|
|
|
|
return (); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
;; |
|
|
|
|