tx · DUKaYB4ksf4NKjtVmDvGbDYXR5TcvP5UYCCQrSsbMrUd

3N2nCHvKXtFH8RUsGQB4LVEwVEWfTsT5i2B:  -0.01400000 Waves

2019.07.14 20:04 [585693] smart account 3N2nCHvKXtFH8RUsGQB4LVEwVEWfTsT5i2B > SELF 0.00000000 Waves

{ "type": 13, "id": "DUKaYB4ksf4NKjtVmDvGbDYXR5TcvP5UYCCQrSsbMrUd", "fee": 1400000, "feeAssetId": null, "timestamp": 1563123896463, "version": 1, "sender": "3N2nCHvKXtFH8RUsGQB4LVEwVEWfTsT5i2B", "senderPublicKey": "6NXakHCUpkyyHNuwDVZ4gYubvvbuP2qL6v2WzJhniSN1", "proofs": [ "4qLeU55KMzjmBzubRgih4BDN3sE4JWWQSkyKdJARUsCDtZKrAERQj4xXyDmeUvn1KL5ccuaD2uGikJYCq4JF7wB1" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAA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QAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAAxnZXRLZXlDb21taXQAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAARoYXNoCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0S2V5Q29tbWl0c0NvdW50AAAAAQUAAAAEaXRlbQkAAGQAAAACBQAAAAdjb21taXRzAAAAAAAAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAAAAAAAIFAAAAB2NvbW1pdHMFAAAABlZPVEVSUwUAAAAGUkVWRUFMBQAAAAZWT1RJTkcFAAAAA25pbAAAAABscr+9", "chainId": 84, "height": 585693, "spentComplexity": 0 } View: original | compacted Prev: D33jZWT2RVYXzqGTYLoE1SZwwAWUPuLSwfUgcnRPuhs9 Next: AbFezWKcVebib62QZjWMBkmNvuUEwmpo78eQzbVxSpY4 Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let VOTERS = 3
5+
6+let QUORUM = 2
7+
8+let VOTING = "voting"
9+
10+let REVEAL = "reveal"
11+
12+let FEATURED = "featured"
13+
14+let DELISTED = "delisted"
15+
416 let NONE = "none"
517
618 func getNumberByKey (key) = {
2335 }
2436 str
2537 }
38+
39+
40+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
41+
42+
43+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
44+
45+
46+func getKeyCommitsCount (item) = (item + "_commit_count")
47+
48+
49+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
50+
51+
52+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
53+
54+
55+func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
56+
57+
58+func getKeyItemStatus (item) = (item + "_status")
59+
60+
61+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
62+
63+
64+func getKeyVoteCount (item,vote) = ((item + "_res_") + vote)
65+
66+
67+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
2668
2769
2870 func getKeyItemPrice (item) = (item + "_price")
5698
5799
58100 @Callable(i)
59-func addItem (title,price,data) = {
60- let supplierAddress = toBase58String(i.caller.bytes)
61- let item = getKeyItem(supplierAddress, title)
62- if ((0 >= price))
63- then throw("Il prezzo non può essere negativo o zero")
64- else if ((getValueItemSupplier(title) != NONE))
65- then throw("Il prodotto esiste già")
66- else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
67- }
68-
69-
70-
71-@Callable(i)
72-func purchase (itemID) = {
73- let pymt = extract(i.payment)
74- if (!(isDefined(itemID)))
75- then throw("Specificare il prodotto che si vuole comprare")
76- else if (isDefined(pymt.assetId))
77- then throw("Utilizzare solo WAVES per il pagamento")
78- else {
79- let price = getValueItemPrice(itemID)
80- if ((price > pymt.amount))
81- then throw("L'offerta non può essere inferiore al prezzo")
82- else if ((pymt.amount > price))
83- then throw("L'offerta non può essere superiore al prezzo")
84- else {
85- let supplierAddress = getValueItemSupplier(itemID)
86- if ((supplierAddress == NONE))
87- then throw("Non esiste un fornitore")
88- else {
89- let callerAddress = toBase58String(i.caller.bytes)
90- WriteSet([DataEntry(getKeyUserItemCounter(callerAddress, itemID), (getValueUserItemCounter(callerAddress, itemID) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pymt.amount))])
91- }
92- }
93- }
94- }
95-
96-
97-
98-@Callable(i)
99-func withdraw () = {
100- let supplierAddress = toBase58String(i.caller.bytes)
101- let balance = getValueBalanceSupplier(supplierAddress)
102- if ((0 >= balance))
103- then throw("Nulla da trasferire")
104- else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
101+func voteCommit (item,hash) = {
102+ let user = toBase58String(i.caller.bytes)
103+ let commits = getValueCommitsCount(item)
104+ let status = getValueItemStatus(item)
105+ if ((commits >= VOTERS))
106+ then throw("Raggiunto il numero massimo di voti")
107+ else if ((getValueCommit(item, user) != NONE))
108+ then throw("Hai già espresso un voto per questo articolo")
109+ else if ((getKeyItemSupplier(item) == NONE))
110+ then throw("L'articolo che vuoi votare non esiste")
111+ else if (if ((status != NONE))
112+ then (status != VOTING)
113+ else false)
114+ then throw("Votazione non possibile")
115+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
116+ then REVEAL
117+ else VOTING)])
105118 }
106119
107120
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let VOTERS = 3
5+
6+let QUORUM = 2
7+
8+let VOTING = "voting"
9+
10+let REVEAL = "reveal"
11+
12+let FEATURED = "featured"
13+
14+let DELISTED = "delisted"
15+
416 let NONE = "none"
517
618 func getNumberByKey (key) = {
719 let num = match getInteger(this, key) {
820 case a: Int =>
921 a
1022 case _ =>
1123 0
1224 }
1325 num
1426 }
1527
1628
1729 func getStrByKey (key) = {
1830 let str = match getString(this, key) {
1931 case a: String =>
2032 a
2133 case _ =>
2234 NONE
2335 }
2436 str
2537 }
38+
39+
40+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
41+
42+
43+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
44+
45+
46+func getKeyCommitsCount (item) = (item + "_commit_count")
47+
48+
49+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
50+
51+
52+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
53+
54+
55+func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
56+
57+
58+func getKeyItemStatus (item) = (item + "_status")
59+
60+
61+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
62+
63+
64+func getKeyVoteCount (item,vote) = ((item + "_res_") + vote)
65+
66+
67+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
2668
2769
2870 func getKeyItemPrice (item) = (item + "_price")
2971
3072
3173 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3274
3375
3476 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
3577
3678
3779 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
3880
3981
4082 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4183
4284
4385 func getKeyItemData (item) = (item + "_data")
4486
4587
4688 func getKeyItemSupplier (item) = (item + "_owner")
4789
4890
4991 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5092
5193
5294 func getKeyBalanceSupplier (account) = (account + "_balance")
5395
5496
5597 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5698
5799
58100 @Callable(i)
59-func addItem (title,price,data) = {
60- let supplierAddress = toBase58String(i.caller.bytes)
61- let item = getKeyItem(supplierAddress, title)
62- if ((0 >= price))
63- then throw("Il prezzo non può essere negativo o zero")
64- else if ((getValueItemSupplier(title) != NONE))
65- then throw("Il prodotto esiste già")
66- else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
67- }
68-
69-
70-
71-@Callable(i)
72-func purchase (itemID) = {
73- let pymt = extract(i.payment)
74- if (!(isDefined(itemID)))
75- then throw("Specificare il prodotto che si vuole comprare")
76- else if (isDefined(pymt.assetId))
77- then throw("Utilizzare solo WAVES per il pagamento")
78- else {
79- let price = getValueItemPrice(itemID)
80- if ((price > pymt.amount))
81- then throw("L'offerta non può essere inferiore al prezzo")
82- else if ((pymt.amount > price))
83- then throw("L'offerta non può essere superiore al prezzo")
84- else {
85- let supplierAddress = getValueItemSupplier(itemID)
86- if ((supplierAddress == NONE))
87- then throw("Non esiste un fornitore")
88- else {
89- let callerAddress = toBase58String(i.caller.bytes)
90- WriteSet([DataEntry(getKeyUserItemCounter(callerAddress, itemID), (getValueUserItemCounter(callerAddress, itemID) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pymt.amount))])
91- }
92- }
93- }
94- }
95-
96-
97-
98-@Callable(i)
99-func withdraw () = {
100- let supplierAddress = toBase58String(i.caller.bytes)
101- let balance = getValueBalanceSupplier(supplierAddress)
102- if ((0 >= balance))
103- then throw("Nulla da trasferire")
104- else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
101+func voteCommit (item,hash) = {
102+ let user = toBase58String(i.caller.bytes)
103+ let commits = getValueCommitsCount(item)
104+ let status = getValueItemStatus(item)
105+ if ((commits >= VOTERS))
106+ then throw("Raggiunto il numero massimo di voti")
107+ else if ((getValueCommit(item, user) != NONE))
108+ then throw("Hai già espresso un voto per questo articolo")
109+ else if ((getKeyItemSupplier(item) == NONE))
110+ then throw("L'articolo che vuoi votare non esiste")
111+ else if (if ((status != NONE))
112+ then (status != VOTING)
113+ else false)
114+ then throw("Votazione non possibile")
115+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
116+ then REVEAL
117+ else VOTING)])
105118 }
106119
107120

github/deemru/w8io/026f985 
34.45 ms