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:AAIDAAAAAAAAAAAAAAAdAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAET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AAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAAxnZXRLZXlDb21taXQAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAARoYXNoCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0S2V5Q29tbWl0c0NvdW50AAAAAQUAAAAEaXRlbQkAAGQAAAACBQAAAAdjb21taXRzAAAAAAAAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAAAAAAAIFAAAAB2NvbW1pdHMFAAAABlZPVEVSUwUAAAAGUkVWRUFMBQAAAAZWT1RJTkcFAAAAA25pbAAAAABscr+9", "chainId": 84, "height": 585693, "spentComplexity": 0 } View: original | compacted Prev: D33jZWT2RVYXzqGTYLoE1SZwwAWUPuLSwfUgcnRPuhs9 Next: AbFezWKcVebib62QZjWMBkmNvuUEwmpo78eQzbVxSpY4 Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# 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 | + | ||
4 | 16 | let NONE = "none" | |
5 | 17 | ||
6 | 18 | func getNumberByKey (key) = { | |
23 | 35 | } | |
24 | 36 | str | |
25 | 37 | } | |
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)) | |
26 | 68 | ||
27 | 69 | ||
28 | 70 | func getKeyItemPrice (item) = (item + "_price") | |
56 | 98 | ||
57 | 99 | ||
58 | 100 | @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)]) | |
105 | 118 | } | |
106 | 119 | ||
107 | 120 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# 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 | + | ||
4 | 16 | let NONE = "none" | |
5 | 17 | ||
6 | 18 | func getNumberByKey (key) = { | |
7 | 19 | let num = match getInteger(this, key) { | |
8 | 20 | case a: Int => | |
9 | 21 | a | |
10 | 22 | case _ => | |
11 | 23 | 0 | |
12 | 24 | } | |
13 | 25 | num | |
14 | 26 | } | |
15 | 27 | ||
16 | 28 | ||
17 | 29 | func getStrByKey (key) = { | |
18 | 30 | let str = match getString(this, key) { | |
19 | 31 | case a: String => | |
20 | 32 | a | |
21 | 33 | case _ => | |
22 | 34 | NONE | |
23 | 35 | } | |
24 | 36 | str | |
25 | 37 | } | |
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)) | |
26 | 68 | ||
27 | 69 | ||
28 | 70 | func getKeyItemPrice (item) = (item + "_price") | |
29 | 71 | ||
30 | 72 | ||
31 | 73 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | 74 | ||
33 | 75 | ||
34 | 76 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | 77 | ||
36 | 78 | ||
37 | 79 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
38 | 80 | ||
39 | 81 | ||
40 | 82 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
41 | 83 | ||
42 | 84 | ||
43 | 85 | func getKeyItemData (item) = (item + "_data") | |
44 | 86 | ||
45 | 87 | ||
46 | 88 | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | 89 | ||
48 | 90 | ||
49 | 91 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | 92 | ||
51 | 93 | ||
52 | 94 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | 95 | ||
54 | 96 | ||
55 | 97 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 98 | ||
57 | 99 | ||
58 | 100 | @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)]) | |
105 | 118 | } | |
106 | 119 | ||
107 | 120 |
github/deemru/w8io/026f985 34.45 ms ◑