|
|
|
@ -10,25 +10,28 @@
|
|
|
|
|
;; cell pricing |
|
|
|
|
;; uint256(key) owner_key |
|
|
|
|
;; address owner_address |
|
|
|
|
;; cell uri_scheme: prefix slice as a cell, then postfix ('.json') slice as a cell |
|
|
|
|
|
|
|
|
|
(cell, cell, cell, int, slice) load_data() inline { |
|
|
|
|
(cell, cell, cell, int, slice, cell) load_data() inline { |
|
|
|
|
var ds = get_data().begin_parse(); |
|
|
|
|
return ( |
|
|
|
|
ds~load_ref(), ;; content |
|
|
|
|
ds~load_ref(), ;; nft_item_code |
|
|
|
|
ds~load_ref(), ;; pricing |
|
|
|
|
ds~load_uint(256), ;; owner key |
|
|
|
|
ds~load_msg_addr() ;; owner address |
|
|
|
|
ds~load_msg_addr(), ;; owner address |
|
|
|
|
ds~load_ref() ;; uri_scheme |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
() save_data(cell content, cell nft_item_code, cell pricing, int owner_key, slice owner_addr) impure inline { |
|
|
|
|
() save_data(cell content, cell nft_item_code, cell pricing, int owner_key, slice owner_addr, cell uri_scheme) impure inline { |
|
|
|
|
set_data(begin_cell() |
|
|
|
|
.store_ref(content) |
|
|
|
|
.store_ref(nft_item_code) |
|
|
|
|
.store_ref(pricing) |
|
|
|
|
.store_uint(owner_key, 256) |
|
|
|
|
.store_slice(owner_addr) |
|
|
|
|
.store_ref(uri_scheme) |
|
|
|
|
.end_cell()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -50,6 +53,15 @@ cell calculate_nft_item_state_init(int item_index, cell nft_item_code) {
|
|
|
|
|
return begin_cell().store_uint(0, 2).store_dict(nft_item_code).store_dict(data).store_uint(0, 1).end_cell(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cell get_uri(slice domain, cell uri_scheme) { |
|
|
|
|
;; parse the prefix and the postfix out of uri_scheme |
|
|
|
|
slice cs = uri_scheme.begin_parse(); |
|
|
|
|
slice prefix = cs~load_ref().begin_parse(); |
|
|
|
|
slice postfix = cs~load_ref().begin_parse(); |
|
|
|
|
;; create the slice with the uri: prefix + domain + postfix |
|
|
|
|
return begin_cell().store_slice(prefix).store_slice(domain).store_slice(postfix).end_cell(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
slice calculate_nft_item_address(int wc, cell state_init) { |
|
|
|
|
return begin_cell() |
|
|
|
|
.store_uint(4, 3) |
|
|
|
@ -75,7 +87,7 @@ slice calculate_nft_item_address(int wc, cell state_init) {
|
|
|
|
|
send_raw_message(msg.end_cell(), send_mode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
() deploy_nft_item(int item_index, cell nft_item_code, cell nft_content) impure { |
|
|
|
|
() deploy_nft_item(int item_index, cell nft_item_code, cell nft_payload) impure { |
|
|
|
|
cell state_init = calculate_nft_item_state_init(item_index, nft_item_code); |
|
|
|
|
slice nft_address = calculate_nft_item_address(workchain(), state_init); |
|
|
|
|
var msg = begin_cell() |
|
|
|
@ -84,7 +96,7 @@ slice calculate_nft_item_address(int wc, cell state_init) {
|
|
|
|
|
.store_coins(0) |
|
|
|
|
.store_uint(4 + 2 + 1, 1 + 4 + 4 + 64 + 32 + 1 + 1 + 1) |
|
|
|
|
.store_ref(state_init) |
|
|
|
|
.store_ref(nft_content); |
|
|
|
|
.store_ref(nft_payload); |
|
|
|
|
send_raw_message(msg.end_cell(), 64); ;; carry all the remaining value of the inbound message, fee deducted from amount |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -107,7 +119,7 @@ int verify_signature(slice signature, slice sender_address, slice domain, int ow
|
|
|
|
|
|
|
|
|
|
int op = in_msg_body~load_uint(32); |
|
|
|
|
|
|
|
|
|
var (content, nft_item_code, pricing, key, addr) = load_data(); |
|
|
|
|
var (content, nft_item_code, pricing, key, addr, uri_scheme) = load_data(); |
|
|
|
|
|
|
|
|
|
if (op == 0) { ;; deploy new nft |
|
|
|
|
int now_time = now(); |
|
|
|
@ -122,14 +134,13 @@ int verify_signature(slice signature, slice sender_address, slice domain, int ow
|
|
|
|
|
slice sender_address = cs~load_msg_addr(); |
|
|
|
|
if (key != 0) { |
|
|
|
|
slice signature = decode_asciicode(signature_encoded); |
|
|
|
|
int bbb = signature.preload_uint(8); |
|
|
|
|
;; throw(300 + slice_bits(signature)); |
|
|
|
|
throw_unless(205, verify_signature(signature, sender_address, domain, key)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cell nft_content = begin_cell() |
|
|
|
|
.store_slice(sender_address) |
|
|
|
|
.store_ref(begin_cell().store_slice(domain).end_cell()) |
|
|
|
|
.store_ref(get_uri(domain, uri_scheme)) |
|
|
|
|
.end_cell(); |
|
|
|
|
deploy_nft_item(item_index, nft_item_code, nft_content); |
|
|
|
|
return (); |
|
|
|
@ -151,12 +162,12 @@ int verify_signature(slice signature, slice sender_address, slice domain, int ow
|
|
|
|
|
;; Get methods |
|
|
|
|
|
|
|
|
|
(int, cell, slice) get_collection_data() method_id { |
|
|
|
|
var (content, nft_item_code, pricing, key, addr) = load_data(); |
|
|
|
|
var (content, nft_item_code, pricing, key, addr, uri_scheme) = load_data(); |
|
|
|
|
return (-1, content, zero_address()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
slice get_nft_address_by_index(int index) method_id { |
|
|
|
|
var (content, nft_item_code, pricing, key, addr) = load_data(); |
|
|
|
|
var (content, nft_item_code, pricing, key, addr, uri_scheme) = load_data(); |
|
|
|
|
cell state_init = calculate_nft_item_state_init(index, nft_item_code); |
|
|
|
|
return calculate_nft_item_address(workchain(), state_init); |
|
|
|
|
} |
|
|
|
@ -166,7 +177,7 @@ cell get_nft_content(int index, cell individual_nft_content) method_id {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int get_price(slice domain) method_id { |
|
|
|
|
var (content, nft_item_code, pricing, key, addr) = load_data(); |
|
|
|
|
var (content, nft_item_code, pricing, key, addr, uri_scheme) = load_data(); |
|
|
|
|
return calcprice(domain, pricing); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|