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+JbV1o7QQIJssPuN7nyhSuLgAWQqXd2UgJecSzNQUgAAAAABE5PTkUCAAAABG5vbmUAAAAABlZPVEVSUwAAAAAAAAAAAwAAAAAGUVVPUlVNAAAAAAAAAAACAAAAAAZWT1RJTkcCAAAABnZvdGluZwAAAAAGUkVWRUFMAgAAAAZyZXZlYWwAAAAACEZFQVRVUkVEAgAAAAhmZWF0dXJlZAAAAAAIREVMSVNIRUQCAAAACGRlbGlzaGVkAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAA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4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAAxwdWJLZXlDb29wZXIGCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAQUAAAAMcHViS2V5Q29vcGVyBgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAIFAAAADHB1YktleUNvb3BlcgAAAAAAAAAAAQAAAAAAAAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAOb3duZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYJAABnAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAC3NpZ25lZEFsaWNlBQAAAAlzaWduZWRCb2IFAAAADHNpZ25lZENvb3BlcgAAAAAAAAAAAuA/las=", "height": 1796627, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4p9i8s8ELYDDweTxgtKUbG3zXP2BuuBQLg1VDsXVNwmL Next: C6LoWN2LGsPMNYmD3EZK9bb7CBHGGjfYHB3B5VhJkmj3 Diff:
OldNewDifferences
1010 let pubKeyCooper = base58'EisxKQktzqqd4UsxE7UgVjSHqoWindUpjoB7dsDwfG4o'
1111
1212 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"
1325
1426 func getNumberByKey (key) = {
1527 let num = match getInteger(this, key) {
6375 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6476
6577
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+
66108 @Callable(i)
67109 func addItem (title,price,data) = {
68110 let supplierAddress = toBase58String(i.caller.bytes)
109151 }
110152
111153
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+
112176 @Verifier(tx)
113177 func verify () = {
114178 let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ownerPublicKey = base58'HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq'
55
66 let pubKeyAlice = base58'HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq'
77
88 let pubKeyBob = base58'B1R7zeh6VgTv4Xxe3aHhdoZ9aQgWcqN8LFC9smacE96r'
99
1010 let pubKeyCooper = base58'EisxKQktzqqd4UsxE7UgVjSHqoWindUpjoB7dsDwfG4o'
1111
1212 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"
1325
1426 func getNumberByKey (key) = {
1527 let num = match getInteger(this, key) {
1628 case t: Int =>
1729 t
1830 case _ =>
1931 0
2032 }
2133 num
2234 }
2335
2436
2537 func getStrByKey (key) = {
2638 let str = match getString(this, key) {
2739 case t: String =>
2840 t
2941 case _ =>
3042 NONE
3143 }
3244 str
3345 }
3446
3547
3648 func getKeyItemPrice (item) = (item + "_price")
3749
3850
3951 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
4052
4153
4254 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
4355
4456
4557 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4658
4759
4860 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4961
5062
5163 func getKeyItemData (item) = (item + "_data")
5264
5365
5466 func getKeyItemSupplier (item) = (item + "_owner")
5567
5668
5769 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5870
5971
6072 func getKeyBalanceSupplier (account) = (account + "_balance")
6173
6274
6375 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6476
6577
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+
66108 @Callable(i)
67109 func addItem (title,price,data) = {
68110 let supplierAddress = toBase58String(i.caller.bytes)
69111 let item = getKeyItem(supplierAddress, title)
70112 if ((0 >= price))
71113 then throw("purchase amount cannot be less than item price")
72114 else if ((getValueItemSupplier(item) != NONE))
73115 then throw("an item is already exist")
74116 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
75117 }
76118
77119
78120
79121 @Callable(i)
80122 func purchase (itemKey) = {
81123 let pmt = extract(i.payment)
82124 if (isDefined(pmt.assetId))
83125 then throw("can use WAVES only at the moment")
84126 else if (!(isDefined(itemKey)))
85127 then throw("You must select Item")
86128 else {
87129 let customerAddress = toBase58String(i.caller.bytes)
88130 let price = getValueItemPrice(itemKey)
89131 let supplierAddress = getValueItemSupplier(itemKey)
90132 if ((price > pmt.amount))
91133 then throw("purchase amoun cannot be less than item price")
92134 else if ((pmt.amount > price))
93135 then throw("purchase amoun cannot be higher than item price")
94136 else if ((supplierAddress == NONE))
95137 then throw("supplier does not exist")
96138 else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, itemKey), (getValueUserItemCounter(customerAddress, itemKey) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
97139 }
98140 }
99141
100142
101143
102144 @Callable(i)
103145 func withdraw () = {
104146 let supplierAddress = toBase58String(i.caller.bytes)
105147 let balance = getValueBalanceSupplier(supplierAddress)
106148 if ((0 >= balance))
107149 then throw("no money - no honey")
108150 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
109151 }
110152
111153
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+
112176 @Verifier(tx)
113177 func verify () = {
114178 let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice))
115179 then true
116180 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyAlice))
117181 then true
118182 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyAlice))
119183 then 1
120184 else 0
121185 let signedBob = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyBob))
122186 then true
123187 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyBob))
124188 then true
125189 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyBob))
126190 then 1
127191 else 0
128192 let signedCooper = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyCooper))
129193 then true
130194 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyCooper))
131195 then true
132196 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyCooper))
133197 then 1
134198 else 0
135199 match tx {
136200 case d: SetScriptTransaction =>
137201 sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey)
138202 case d: DataTransaction =>
139203 true
140204 case _ =>
141205 (((signedAlice + signedBob) + signedCooper) >= 2)
142206 }
143207 }
144208

github/deemru/w8io/026f985 
26.56 ms