Skip to content

Commit 7274302

Browse files
authored
Merge pull request #9 from Yakuhito/improvssss
Improvssss
2 parents da96f14 + 2fc763e commit 7274302

File tree

114 files changed

+3000
-2480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3000
-2480
lines changed

include/secure_nft.clib

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(
22
(include curry.clib)
3+
(include sha256tree.clib)
34

45
; this function ensures that an NFT with a given inner puzzle hash is spent
56
; launcher_id is computed from the current coin's if (plus other truths)
@@ -24,13 +25,7 @@
2425
(coinid
2526
launcher_id ; parent id
2627
(curry_hashes SINGLETON_MOD_HASH
27-
(sha256 2
28-
(sha256 1 SINGLETON_MOD_HASH)
29-
(sha256 2
30-
(sha256 1 launcher_id)
31-
(sha256 1 LAUNCHER_MOD_HASH)
32-
)
33-
) ; sha256tree singleton struct
28+
(sha256tree (c SINGLETON_MOD_HASH (c launcher_id LAUNCHER_MOD_HASH)))
3429
(curry_hashes NFT_STATE_LAYER_MOD_HASH
3530
(sha256 1 NFT_STATE_LAYER_MOD_HASH)
3631
(sha256_one) ; metadata is ()
@@ -39,13 +34,7 @@
3934
(sha256 1 NFT_OWNERSHIP_MOD_HASH)
4035
(sha256_one) ; owner is ()
4136
(curry_hashes TRANSFER_PROGRAM_MOD_HASH
42-
(sha256 2
43-
(sha256 1 SINGLETON_MOD_HASH)
44-
(sha256 2
45-
(sha256 1 launcher_id)
46-
(sha256 1 LAUNCHER_MOD_HASH)
47-
)
48-
) ; sha256tree singleton struct
37+
(sha256tree (c SINGLETON_MOD_HASH (c launcher_id LAUNCHER_MOD_HASH)))
4938
ROYALTY_ADDRESS_HASH
5039
(sha256 1 TRADE_PRICE_PERCENTAGE)
5140
) ; transfer program

include/slots.clib

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111
)
1212

13-
(defun create_slot (SLOT_1ST_CURRY_HASH slot_value_hash hint)
13+
(defun create_slot_with_hint (SLOT_1ST_CURRY_HASH slot_value_hash hint)
1414
(list
1515
CREATE_COIN
1616
(curry_hashes SLOT_1ST_CURRY_HASH
@@ -21,6 +21,17 @@
2121
)
2222
)
2323

24+
(defun create_slot (SLOT_1ST_CURRY_HASH slot_value_hash hint)
25+
(list
26+
CREATE_COIN
27+
(curry_hashes SLOT_1ST_CURRY_HASH
28+
(sha256 1 slot_value_hash)
29+
)
30+
0
31+
(list SLOT_1ST_CURRY_HASH)
32+
)
33+
)
34+
2435
(defun spend_slot_inline (SLOT_1ST_CURRY_HASH slot_value_hash)
2536
(list
2637
SEND_MESSAGE
@@ -32,7 +43,7 @@
3243
)
3344
)
3445

35-
(defun create_slot_inline (SLOT_1ST_CURRY_HASH slot_value_hash hint)
46+
(defun create_slot_with_hint_inline (SLOT_1ST_CURRY_HASH slot_value_hash hint)
3647
(list
3748
CREATE_COIN
3849
(curry_hashes_inline SLOT_1ST_CURRY_HASH
@@ -42,4 +53,15 @@
4253
(list hint)
4354
)
4455
)
56+
57+
(defun create_slot_inline (SLOT_1ST_CURRY_HASH slot_value_hash hint)
58+
(list
59+
CREATE_COIN
60+
(curry_hashes_inline SLOT_1ST_CURRY_HASH
61+
(sha256 1 slot_value_hash)
62+
)
63+
0
64+
(list SLOT_1ST_CURRY_HASH)
65+
)
66+
)
4567
)

include/xchandles.clib

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
(
2+
(defun-inline get_xchandles_slot_value_hash (handle_hash neighbors expiration data)
3+
(sha256tree (c
4+
(c handle_hash neighbors)
5+
(c expiration data)
6+
))
7+
)
8+
9+
(defun-inline xchandles_precommitment_value (
10+
cat_maker_hash
11+
cat_maker_solution
12+
pricing_puzzle_hash
13+
pricing_puzzle_solution
14+
handle
15+
secret
16+
start_time
17+
owner_launcher_id
18+
resolved_data
19+
)
20+
(sha256tree
21+
(c
22+
(c
23+
(c cat_maker_hash cat_maker_solution)
24+
(c pricing_puzzle_hash pricing_puzzle_solution)
25+
)
26+
(c
27+
(c handle secret)
28+
(c start_time (c owner_launcher_id resolved_data))
29+
)
30+
)
31+
)
32+
)
33+
)

puzzles/actions/auctions/end.clsp.hex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FAIL: can't compile ("sha256tree" (c 1 ("list" ("list" "CREATE_COIN" "King" "asset_amount" ("list" "King"))))), unknown operator ("sha256tree" (c 1 ("list" ("list" "CREATE_COIN" "King" "asset_amount" ("list" "King")))))
1+
FAIL: can't compile ("take_comissions" "AUCTIONEER_PUZZLE_HASH" "bid_amount" (26982 (> "fee_type" 2) (- "remaining_funds" (26982 (= "fee_type" ()) (/ (* "bid_amount" "fee_arg") 10000) "fee_arg")) "remaining_funds") "remaining_fees"), unknown operator ("take_comissions" "AUCTIONEER_PUZZLE_HASH" "bid_amount" (26982 (> "fee_type" 2) (- "remaining_funds" (26982 (= "fee_type" ()) (/ (* "bid_amount" "fee_arg") 10000) "fee_arg")) "remaining_funds") "remaining_fees")

puzzles/actions/catalog/refund.clsp

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,28 @@
1919
)
2020
)
2121
)
22-
(
22+
(
23+
precommited_cat_maker_hash ; (sha256tree precommited_cat_maker_reveal)
2324
precommited_cat_maker_reveal
24-
precommited_cat_maker_hash
2525
precommited_cat_maker_solution
2626
tail_hash ; full TAIL in the reveal of the pre-commit coin
2727
initial_nft_owner_ph ; also included in the pre-commit coin
2828
refund_puzzle_hash_hash ; used to compute precommit coin puzzle hash
2929
precommit_amount . ; amount of the pre-commit coin
30-
neighbors_hash ; (sha256sum (left_tail_hash . right_tail_hash))
30+
neighbors ; (left_tail_hash . right_tail_hash)
3131
) ; solution
3232
)
3333
(include condition_codes.clib)
34-
(include secure_nft.clib)
3534
(include sha256tree.clib)
35+
(include curry.clib)
3636
(include slots.clib)
3737

38-
(defun get_slot_value_hash (value neighbors_hash)
39-
(sha256 2 (sha256 1 value) neighbors_hash)
40-
)
41-
42-
(defun main (SLOT_1ST_CURRY_HASH slot_value_hash slot_hint slot_spend_needed base_conditions)
38+
(defun main (SLOT_1ST_CURRY_HASH slot_value_hash slot_spend_needed base_conditions)
4339
(if slot_spend_needed
4440
(c
4541
(spend_slot SLOT_1ST_CURRY_HASH slot_value_hash)
4642
(c
47-
(create_slot SLOT_1ST_CURRY_HASH slot_value_hash slot_hint)
43+
(create_slot SLOT_1ST_CURRY_HASH slot_value_hash)
4844
base_conditions
4945
)
5046
)
@@ -58,8 +54,7 @@
5854
Truth ; nothing changes
5955
(main
6056
SLOT_1ST_CURRY_HASH
61-
(get_slot_value_hash tail_hash neighbors_hash)
62-
tail_hash
57+
(sha256tree (c tail_hash neighbors))
6358
(all
6459
(= Registration_Price precommit_amount)
6560
(= precommited_cat_maker_hash Cat_Maker_Puzzle_Hash)
@@ -69,10 +64,7 @@
6964
(list
7065
CREATE_PUZZLE_ANNOUNCEMENT
7166
(concat '$'
72-
(sha256 2
73-
(sha256 1 tail_hash)
74-
(sha256 1 initial_nft_owner_ph)
75-
) ; (sha256tree (tail_hash . initial_nft_owner_ph))
67+
(sha256tree (c tail_hash initial_nft_owner_ph))
7668
)
7769
)
7870

@@ -83,21 +75,17 @@
8375
0 ; message = 0 = refund
8476
(a
8577
precommited_cat_maker_reveal
86-
(list
78+
(c
8779
(curry_hashes PRECOMMIT_1ST_CURRY_HASH
8880
refund_puzzle_hash_hash
81+
; full precommit value reveal is (TAIL . HASH)
82+
; where HASH = (sha256tree initial_nft_owner_ph cat_maker_hash . cat_maker_solution)
8983
(sha256 2
84+
tail_hash
9085
(sha256 1
91-
(sha256 2
92-
precommited_cat_maker_hash
93-
(sha256tree precommited_cat_maker_solution)
94-
)
95-
)
96-
(sha256 2
97-
(sha256 1 initial_nft_owner_ph)
98-
tail_hash
86+
(sha256tree (c initial_nft_owner_ph (c precommited_cat_maker_hash precommited_cat_maker_solution)))
9987
)
100-
) ; precommit coin reveal will be (c refund_info_hash (c initial_nft_owner_ph TAIL))
88+
)
10189
) ; Inner_Puzzle_Hash
10290
precommited_cat_maker_solution
10391
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ff02ffff01ff02ffff03ffff09ff81afffff02ff2effff04ff02ffff04ff4fff8080808080ffff01ff04ff17ffff02ff36ffff04ff02ffff04ff0bffff04ffff02ff3affff04ff02ffff04ff8202efffff04ff821fefff8080808080ffff04ff8202efffff04ffff22ffff09ff77ff8217ef80ffff09ff81afff578080ffff04ffff04ffff04ff28ffff04ffff0effff0124ffff0bffff0102ffff0bffff0101ff8202ef80ffff0bffff0101ff8205ef808080ff808080ffff04ffff04ff38ffff04ffff0113ffff04ff80ffff04ffff02ff4fffff04ffff02ff2affff04ff02ffff04ff05ffff04ff820befffff04ffff0bffff0102ffff0bffff0101ffff0bffff0102ff81afffff02ff2effff04ff02ffff04ff82016fff808080808080ffff0bffff0102ffff0bffff0101ff8205ef80ff8202ef8080ff808080808080ffff04ff82016fff80808080ffff04ff8217efff808080808080ff808080ff808080808080808080ffff01ff088080ff0180ffff04ffff01ffffff33ff3e42ff02ffff02ffff03ff05ffff01ff0bff81fcffff02ff26ffff04ff02ffff04ff09ffff04ffff02ff2cffff04ff02ffff04ff0dff80808080ff808080808080ffff0181dc80ff0180ffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffffff04ff10ffff04ffff02ff2affff04ff02ffff04ff05ffff04ffff0bffff0101ff0b80ff8080808080ffff04ff80ffff04ffff04ff17ff8080ff8080808080ffff0bff81bcffff02ff26ffff04ff02ffff04ff05ffff04ffff02ff2cffff04ff02ffff04ff07ff80808080ff808080808080ff0bffff0102ffff0bffff0101ff0580ff0b80ffffff0bff14ffff0bff14ff81dcff0580ffff0bff14ff0bff819c8080ff02ffff03ff2fffff01ff04ffff02ff3effff04ff02ffff04ff05ffff04ff0bff8080808080ffff04ffff02ff12ffff04ff02ffff04ff05ffff04ff0bffff04ff17ff808080808080ff5f8080ffff015f80ff0180ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff2effff04ff02ffff04ff09ff80808080ffff02ff2effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff04ff38ffff04ffff0112ffff04ff80ffff04ffff02ff2affff04ff02ffff04ff05ffff04ffff0bffff0101ff0b80ff8080808080ff8080808080ff018080
1+
ff02ffff01ff02ffff03ffff09ff4fffff02ff2effff04ff02ffff04ff81afff8080808080ffff01ff04ff17ffff02ff16ffff04ff02ffff04ff0bffff04ffff02ff2effff04ff02ffff04ffff04ff8202efff821fef80ff80808080ffff04ffff22ffff09ff77ff8217ef80ffff09ff4fff578080ffff04ffff04ffff04ff28ffff04ffff0effff0124ffff02ff2effff04ff02ffff04ffff04ff8202efff8205ef80ff8080808080ff808080ffff04ffff04ff38ffff04ffff0113ffff04ff80ffff04ffff02ff81afffff04ffff02ff2affff04ff02ffff04ff05ffff04ff820befffff04ffff0bffff0102ff8202efffff0bffff0101ffff02ff2effff04ff02ffff04ffff04ff8205efffff04ff4fff82016f8080ff808080808080ff808080808080ff82016f8080ffff04ff8217efff808080808080ff808080ff8080808080808080ffff01ff088080ff0180ffff04ffff01ffffff33ff3e42ff02ffff02ffff03ff05ffff01ff0bff81fcffff02ff3affff04ff02ffff04ff09ffff04ffff02ff2cffff04ff02ffff04ff0dff80808080ff808080808080ffff0181dc80ff0180ffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffffff04ff10ffff04ffff02ff2affff04ff02ffff04ff05ffff04ffff0bffff0101ff0b80ff8080808080ffff04ff80ffff04ffff04ff05ff8080ff8080808080ffff0bff81bcffff02ff3affff04ff02ffff04ff05ffff04ffff02ff2cffff04ff02ffff04ff07ff80808080ff808080808080ff0bff14ffff0bff14ff81dcff0580ffff0bff14ff0bff819c8080ffff02ffff03ff17ffff01ff04ffff02ff3effff04ff02ffff04ff05ffff04ff0bff8080808080ffff04ffff02ff12ffff04ff02ffff04ff05ffff04ff0bff8080808080ff2f8080ffff012f80ff0180ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff2effff04ff02ffff04ff09ff80808080ffff02ff2effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff04ff38ffff04ffff0112ffff04ff80ffff04ffff02ff2affff04ff02ffff04ff05ffff04ffff0bffff0101ff0b80ff8080808080ff8080808080ff018080

puzzles/actions/catalog/register.clsp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
)
4747
(include condition_codes.clib)
4848
(include secure_nft.clib)
49-
(include sha256tree.clib)
5049
(include slots.clib)
5150

5251
(defun create_prelauncher_and_assert_launcher (
@@ -77,11 +76,8 @@
7776
)
7877
)
7978

80-
(defun get_slot_value_hash (value left_value right_value)
81-
(sha256 2
82-
(sha256 1 value)
83-
(sha256 2 (sha256 1 left_value) (sha256 1 right_value))
84-
)
79+
(defun-inline get_slot_value_hash (value left_value right_value)
80+
(sha256tree (c value (c left_value right_value)))
8581
)
8682

8783
(if (all
@@ -104,10 +100,7 @@
104100
(list
105101
CREATE_PUZZLE_ANNOUNCEMENT
106102
(concat 'r'
107-
(sha256 2
108-
(sha256 1 tail_hash)
109-
(sha256 1 initial_nft_owner_ph)
110-
) ; (sha256tree (tail_hash . initial_nft_owner_ph))
103+
(sha256tree (c tail_hash initial_nft_owner_ph))
111104
)
112105
)
113106

@@ -123,17 +116,14 @@
123116
; create new slot
124117
(create_slot SLOT_1ST_CURRY_HASH
125118
(get_slot_value_hash tail_hash left_tail_hash right_tail_hash)
126-
tail_hash
127119
)
128120
; create new left slot
129121
(create_slot SLOT_1ST_CURRY_HASH
130122
(get_slot_value_hash left_tail_hash left_left_tail_hash tail_hash)
131-
left_tail_hash
132123
)
133124
; create new right slot
134125
(create_slot SLOT_1ST_CURRY_HASH
135126
(get_slot_value_hash right_tail_hash tail_hash right_right_tail_hash)
136-
right_tail_hash
137127
)
138128

139129
; consume precommit coin
@@ -143,18 +133,17 @@
143133
1 ; message = 1 = spend to payout puzzle hash
144134
(a
145135
cat_maker_reveal
146-
(list
136+
(c
147137
(curry_hashes PRECOMMIT_1ST_CURRY_HASH
148138
refund_puzzle_hash_hash
139+
; full precommit value reveal is (TAIL . HASH)
140+
; where HASH = (sha256tree initial_nft_owner_ph cat_maker_hash . cat_maker_solution)
149141
(sha256 2
142+
tail_hash
150143
(sha256 1
151-
(sha256 2 Cat_Maker_Puzzle_Hash (sha256tree cat_maker_solution))
144+
(sha256tree (c initial_nft_owner_ph (c Cat_Maker_Puzzle_Hash cat_maker_solution)))
152145
)
153-
(sha256 2
154-
(sha256 1 initial_nft_owner_ph)
155-
tail_hash
156-
)
157-
) ; precommit coin reveal will be (c refund_info_hash (c initial_nft_owner_ph TAIL))
146+
)
158147
) ; Inner_Puzzle_Hash
159148
cat_maker_solution
160149
)

0 commit comments

Comments
 (0)