tx · 8RERozAWNashVZxfUPsJ17kmpiRKb4Hg9VJWgHC4tijv 3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP: -0.01400000 Waves 2021.11.18 17:56 [1796627] smart account 3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP > SELF 0.00000000 Waves
{ "type": 13, "id": "8RERozAWNashVZxfUPsJ17kmpiRKb4Hg9VJWgHC4tijv", "fee": 1400000, "feeAssetId": null, "timestamp": 1637247427906, "version": 2, "chainId": 84, "sender": "3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP", "senderPublicKey": "HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq", "proofs": [ "32GqwwThhNMm4CHYKXsinZ3Qnyxg1SDtooc9sLhKMgGSsYSbc6jvBRb6GYFp2ewtHB9g6Dtv7FbTP2ySsa58gwWU" ], "script": "base64:AAIDAAAAAAAAABYIARIFCgMIAQgSAwoBCBIAEgQKAggIAAAAIQAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIPr6UCy9pj38gKwWFLWxgxjXdgaG+HWNPUCI9qmcr64gAAAAAAtwdWJLZXlBbGljZQEAAAAg+vpQLL2mPfyArBYUtbGDGNd2Bob4dY09QIj2qZyvriAAAAAACXB1YktleUJvYgEAAAAglLAkeqfLsZeQupv/2xfSzDiecKRph4OtJwpInBvH10sAAAAADHB1YktleUNvb3BlcgEAAAAgy+JbV1o7QQIJssPuN7nyhSuLgAWQqXd2UgJecSzNQUgAAAAABE5PTkUCAAAABG5vbmUAAAAABlZPVEVSUwAAAAAAAAAAAwAAAAAGUVVPUlVNAAAAAAAAAAACAAAAAAZWT1RJTkcCAAAABnZvdGluZwAAAAAGUkVWRUFMAgAAAAZyZXZlYWwAAAAACEZFQVRVUkVEAgAAAAhmZWF0dXJlZAAAAAAIREVMSVNIRUQCAAAACGRlbGlzaGVkAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQ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AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAAxwdWJLZXlDb29wZXIGCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAQUAAAAMcHViS2V5Q29vcGVyBgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAIFAAAADHB1YktleUNvb3BlcgAAAAAAAAAAAQAAAAAAAAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAOb3duZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYJAABnAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAC3NpZ25lZEFsaWNlBQAAAAlzaWduZWRCb2IFAAAADHNpZ25lZENvb3BlcgAAAAAAAAAAAuA/las=", "height": 1796627, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4p9i8s8ELYDDweTxgtKUbG3zXP2BuuBQLg1VDsXVNwmL Next: C6LoWN2LGsPMNYmD3EZK9bb7CBHGGjfYHB3B5VhJkmj3 Diff:
Old | New | Differences | |
---|---|---|---|
10 | 10 | let pubKeyCooper = base58'EisxKQktzqqd4UsxE7UgVjSHqoWindUpjoB7dsDwfG4o' | |
11 | 11 | ||
12 | 12 | let NONE = "none" | |
13 | + | ||
14 | + | let VOTERS = 3 | |
15 | + | ||
16 | + | let QUORUM = 2 | |
17 | + | ||
18 | + | let VOTING = "voting" | |
19 | + | ||
20 | + | let REVEAL = "reveal" | |
21 | + | ||
22 | + | let FEATURED = "featured" | |
23 | + | ||
24 | + | let DELISHED = "delished" | |
13 | 25 | ||
14 | 26 | func getNumberByKey (key) = { | |
15 | 27 | let num = match getInteger(this, key) { | |
63 | 75 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
64 | 76 | ||
65 | 77 | ||
78 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
79 | + | ||
80 | + | ||
81 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
82 | + | ||
83 | + | ||
84 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
85 | + | ||
86 | + | ||
87 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
88 | + | ||
89 | + | ||
90 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
91 | + | ||
92 | + | ||
93 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
94 | + | ||
95 | + | ||
96 | + | func getKeyItemStatus (item) = (item + "_status") | |
97 | + | ||
98 | + | ||
99 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
100 | + | ||
101 | + | ||
102 | + | func getKeyVoteCount (item,vote) = (item + "_comcnt") | |
103 | + | ||
104 | + | ||
105 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
106 | + | ||
107 | + | ||
66 | 108 | @Callable(i) | |
67 | 109 | func addItem (title,price,data) = { | |
68 | 110 | let supplierAddress = toBase58String(i.caller.bytes) | |
109 | 151 | } | |
110 | 152 | ||
111 | 153 | ||
154 | + | ||
155 | + | @Callable(i) | |
156 | + | func voteCommit (item,hash) = if ((getKeyItemSupplier(item) == NONE)) | |
157 | + | then throw("item does not exist") | |
158 | + | else { | |
159 | + | let user = toBase58String(i.caller.bytes) | |
160 | + | let commits = getValueCommitsCount(item) | |
161 | + | let status = getValueItemStatus(item) | |
162 | + | if ((commits >= VOTERS)) | |
163 | + | then throw("reached max num of voters") | |
164 | + | else if ((getValueCommit(item, user) != NONE)) | |
165 | + | then throw("user has already participated") | |
166 | + | else if (if ((status != NONE)) | |
167 | + | then (status != VOTING) | |
168 | + | else false) | |
169 | + | then throw("voting is not possible") | |
170 | + | else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if (((commits + 1) == VOTERS)) | |
171 | + | then REVEAL | |
172 | + | else VOTING)]) | |
173 | + | } | |
174 | + | ||
175 | + | ||
112 | 176 | @Verifier(tx) | |
113 | 177 | func verify () = { | |
114 | 178 | let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerPublicKey = base58'HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq' | |
5 | 5 | ||
6 | 6 | let pubKeyAlice = base58'HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq' | |
7 | 7 | ||
8 | 8 | let pubKeyBob = base58'B1R7zeh6VgTv4Xxe3aHhdoZ9aQgWcqN8LFC9smacE96r' | |
9 | 9 | ||
10 | 10 | let pubKeyCooper = base58'EisxKQktzqqd4UsxE7UgVjSHqoWindUpjoB7dsDwfG4o' | |
11 | 11 | ||
12 | 12 | let NONE = "none" | |
13 | + | ||
14 | + | let VOTERS = 3 | |
15 | + | ||
16 | + | let QUORUM = 2 | |
17 | + | ||
18 | + | let VOTING = "voting" | |
19 | + | ||
20 | + | let REVEAL = "reveal" | |
21 | + | ||
22 | + | let FEATURED = "featured" | |
23 | + | ||
24 | + | let DELISHED = "delished" | |
13 | 25 | ||
14 | 26 | func getNumberByKey (key) = { | |
15 | 27 | let num = match getInteger(this, key) { | |
16 | 28 | case t: Int => | |
17 | 29 | t | |
18 | 30 | case _ => | |
19 | 31 | 0 | |
20 | 32 | } | |
21 | 33 | num | |
22 | 34 | } | |
23 | 35 | ||
24 | 36 | ||
25 | 37 | func getStrByKey (key) = { | |
26 | 38 | let str = match getString(this, key) { | |
27 | 39 | case t: String => | |
28 | 40 | t | |
29 | 41 | case _ => | |
30 | 42 | NONE | |
31 | 43 | } | |
32 | 44 | str | |
33 | 45 | } | |
34 | 46 | ||
35 | 47 | ||
36 | 48 | func getKeyItemPrice (item) = (item + "_price") | |
37 | 49 | ||
38 | 50 | ||
39 | 51 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
40 | 52 | ||
41 | 53 | ||
42 | 54 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
43 | 55 | ||
44 | 56 | ||
45 | 57 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
46 | 58 | ||
47 | 59 | ||
48 | 60 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
49 | 61 | ||
50 | 62 | ||
51 | 63 | func getKeyItemData (item) = (item + "_data") | |
52 | 64 | ||
53 | 65 | ||
54 | 66 | func getKeyItemSupplier (item) = (item + "_owner") | |
55 | 67 | ||
56 | 68 | ||
57 | 69 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
58 | 70 | ||
59 | 71 | ||
60 | 72 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
61 | 73 | ||
62 | 74 | ||
63 | 75 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
64 | 76 | ||
65 | 77 | ||
78 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
79 | + | ||
80 | + | ||
81 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
82 | + | ||
83 | + | ||
84 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
85 | + | ||
86 | + | ||
87 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
88 | + | ||
89 | + | ||
90 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
91 | + | ||
92 | + | ||
93 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
94 | + | ||
95 | + | ||
96 | + | func getKeyItemStatus (item) = (item + "_status") | |
97 | + | ||
98 | + | ||
99 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
100 | + | ||
101 | + | ||
102 | + | func getKeyVoteCount (item,vote) = (item + "_comcnt") | |
103 | + | ||
104 | + | ||
105 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
106 | + | ||
107 | + | ||
66 | 108 | @Callable(i) | |
67 | 109 | func addItem (title,price,data) = { | |
68 | 110 | let supplierAddress = toBase58String(i.caller.bytes) | |
69 | 111 | let item = getKeyItem(supplierAddress, title) | |
70 | 112 | if ((0 >= price)) | |
71 | 113 | then throw("purchase amount cannot be less than item price") | |
72 | 114 | else if ((getValueItemSupplier(item) != NONE)) | |
73 | 115 | then throw("an item is already exist") | |
74 | 116 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
75 | 117 | } | |
76 | 118 | ||
77 | 119 | ||
78 | 120 | ||
79 | 121 | @Callable(i) | |
80 | 122 | func purchase (itemKey) = { | |
81 | 123 | let pmt = extract(i.payment) | |
82 | 124 | if (isDefined(pmt.assetId)) | |
83 | 125 | then throw("can use WAVES only at the moment") | |
84 | 126 | else if (!(isDefined(itemKey))) | |
85 | 127 | then throw("You must select Item") | |
86 | 128 | else { | |
87 | 129 | let customerAddress = toBase58String(i.caller.bytes) | |
88 | 130 | let price = getValueItemPrice(itemKey) | |
89 | 131 | let supplierAddress = getValueItemSupplier(itemKey) | |
90 | 132 | if ((price > pmt.amount)) | |
91 | 133 | then throw("purchase amoun cannot be less than item price") | |
92 | 134 | else if ((pmt.amount > price)) | |
93 | 135 | then throw("purchase amoun cannot be higher than item price") | |
94 | 136 | else if ((supplierAddress == NONE)) | |
95 | 137 | then throw("supplier does not exist") | |
96 | 138 | else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, itemKey), (getValueUserItemCounter(customerAddress, itemKey) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
97 | 139 | } | |
98 | 140 | } | |
99 | 141 | ||
100 | 142 | ||
101 | 143 | ||
102 | 144 | @Callable(i) | |
103 | 145 | func withdraw () = { | |
104 | 146 | let supplierAddress = toBase58String(i.caller.bytes) | |
105 | 147 | let balance = getValueBalanceSupplier(supplierAddress) | |
106 | 148 | if ((0 >= balance)) | |
107 | 149 | then throw("no money - no honey") | |
108 | 150 | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
109 | 151 | } | |
110 | 152 | ||
111 | 153 | ||
154 | + | ||
155 | + | @Callable(i) | |
156 | + | func voteCommit (item,hash) = if ((getKeyItemSupplier(item) == NONE)) | |
157 | + | then throw("item does not exist") | |
158 | + | else { | |
159 | + | let user = toBase58String(i.caller.bytes) | |
160 | + | let commits = getValueCommitsCount(item) | |
161 | + | let status = getValueItemStatus(item) | |
162 | + | if ((commits >= VOTERS)) | |
163 | + | then throw("reached max num of voters") | |
164 | + | else if ((getValueCommit(item, user) != NONE)) | |
165 | + | then throw("user has already participated") | |
166 | + | else if (if ((status != NONE)) | |
167 | + | then (status != VOTING) | |
168 | + | else false) | |
169 | + | then throw("voting is not possible") | |
170 | + | else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if (((commits + 1) == VOTERS)) | |
171 | + | then REVEAL | |
172 | + | else VOTING)]) | |
173 | + | } | |
174 | + | ||
175 | + | ||
112 | 176 | @Verifier(tx) | |
113 | 177 | func verify () = { | |
114 | 178 | let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice)) | |
115 | 179 | then true | |
116 | 180 | else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyAlice)) | |
117 | 181 | then true | |
118 | 182 | else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyAlice)) | |
119 | 183 | then 1 | |
120 | 184 | else 0 | |
121 | 185 | let signedBob = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyBob)) | |
122 | 186 | then true | |
123 | 187 | else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyBob)) | |
124 | 188 | then true | |
125 | 189 | else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyBob)) | |
126 | 190 | then 1 | |
127 | 191 | else 0 | |
128 | 192 | let signedCooper = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyCooper)) | |
129 | 193 | then true | |
130 | 194 | else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyCooper)) | |
131 | 195 | then true | |
132 | 196 | else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyCooper)) | |
133 | 197 | then 1 | |
134 | 198 | else 0 | |
135 | 199 | match tx { | |
136 | 200 | case d: SetScriptTransaction => | |
137 | 201 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
138 | 202 | case d: DataTransaction => | |
139 | 203 | true | |
140 | 204 | case _ => | |
141 | 205 | (((signedAlice + signedBob) + signedCooper) >= 2) | |
142 | 206 | } | |
143 | 207 | } | |
144 | 208 |
github/deemru/w8io/026f985 26.56 ms ◑