tx · CbG2SFGC41RXzayu92DDGmMNxZmZYAeBVZp6xLcc1k4z 3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6: -0.01400000 Waves 2019.11.16 21:41 [768042] smart account 3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6 > SELF 0.00000000 Waves
{ "type": 13, "id": "CbG2SFGC41RXzayu92DDGmMNxZmZYAeBVZp6xLcc1k4z", "fee": 1400000, "feeAssetId": null, "timestamp": 1573929703578, "version": 1, "sender": "3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6", "senderPublicKey": "8bmUdC19peGBa1TGeRZaZfpuDG6yKaGYBd8FQvcBLAXR", "proofs": [ "67Pe6FfECfb7nsyiMAbNEATRKTMbJjMjivA5Tt1Ar2rvJ8tFyM57dC2Htu6TKkkE5zRLn8Vya1W9AKzjzjiRNQkd" ], "script": "base64:AAIDAAAAAAAAAAgIARIECgIICAAAAB0AAAAABE5PTkUCAAAABG5vbmUAAAAABlZPVEVSUwAAAAAAAAAAAwAAAAAGUVVPUlVNAAAAAAAAAAACAAAAAAZWT1RJTkcCAAAABnZvdGluZwAAAAAGUkVWRUFMAgAAAAZyZXZlYWwAAAAACEZFQVRVUkVEAgAAAAhmZWF0dXJlZAAAAAAIREVMSVNURUQCAAAACGRlbGlzdGVkAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAA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AAACCQEAAAASZ2V0S2V5Q29tbWl0c0NvdW50AAAAAQUAAAAEaXRlbQkAAGQAAAACBQAAAAdjb21taXRzAAAAAAAAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAAAAAAAIFAAAAB2NvbW1pdHMFAAAABlZPVEVSUwUAAAAGUkVWRUFMBQAAAAZWT1RJTkcFAAAAA25pbAAAAAAWmofF", "chainId": 84, "height": 768042, "spentComplexity": 0 } View: original | compacted Prev: 8H87rDQzUsSNTodPrT7ncKhVdCAo1oPipf2QqqTny7k2 Next: 4teELnsVnyY8cpsfBLt2qg8eMfmtr2E2mR8vToU2PMXP Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | - | ||
6 | + | let VOTERS = 3 | |
7 | 7 | ||
8 | + | let QUORUM = 2 | |
8 | 9 | ||
9 | - | ||
10 | + | let VOTING = "voting" | |
10 | 11 | ||
12 | + | let REVEAL = "reveal" | |
11 | 13 | ||
12 | - | ||
14 | + | let FEATURED = "featured" | |
13 | 15 | ||
16 | + | let DELISTED = "delisted" | |
14 | 17 | ||
15 | 18 | func getStrByKey (key) = { | |
16 | 19 | let str = match getString(this, key) { | |
23 | 26 | } | |
24 | 27 | ||
25 | 28 | ||
26 | - | func getKeyItem (supp,title) = ("item_" + toBase58String(sha256(toBytes((supp + title))))) | |
27 | - | ||
28 | - | ||
29 | - | func getValueItemSupp (item) = getStrByKey(getKeyItemSupp(item)) | |
30 | - | ||
31 | - | ||
32 | 29 | func getNumberByKey (key) = { | |
33 | 30 | let num = match getInteger(this, key) { | |
34 | 31 | case a: Int => | |
38 | 35 | } | |
39 | 36 | num | |
40 | 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 + "_comcnt") | |
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)) | |
68 | + | ||
69 | + | ||
70 | + | func getKeyItemPrice (item) = (item + "_price") | |
71 | + | ||
72 | + | ||
73 | + | func getKeyItemData (item) = (item + "_data") | |
74 | + | ||
75 | + | ||
76 | + | func getKeyItemSupp (item) = (item + "_owner") | |
77 | + | ||
78 | + | ||
79 | + | func getKeyItem (supp,title) = ("item_" + toBase58String(sha256(toBytes((supp + title))))) | |
80 | + | ||
81 | + | ||
82 | + | func getValueItemSupp (item) = getStrByKey(getKeyItemSupp(item)) | |
41 | 83 | ||
42 | 84 | ||
43 | 85 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
56 | 98 | ||
57 | 99 | ||
58 | 100 | @Callable(i) | |
59 | - | func withdraw () = { | |
60 | - | let suppAdr = toBase58String(i.caller.bytes) | |
61 | - | let balance = getValueSuppBalance(suppAdr) | |
62 | - | if ((0 >= balance)) | |
63 | - | then throw("insufficient balance") | |
64 | - | else ScriptResult(WriteSet([DataEntry(getKeySuppBalance(suppAdr), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppAdr), 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("reahced max voters") | |
107 | + | else if ((getValueCommit(item, user) != NONE)) | |
108 | + | then throw("user already voted") | |
109 | + | else if ((getKeyItemSupp(item) == NONE)) | |
110 | + | then throw("item does not exist") | |
111 | + | else if (if ((status != NONE)) | |
112 | + | then (status != VOTING) | |
113 | + | else false) | |
114 | + | then throw("vote is not possible") | |
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)]) | |
65 | 118 | } | |
66 | 119 | ||
67 | 120 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | - | ||
6 | + | let VOTERS = 3 | |
7 | 7 | ||
8 | + | let QUORUM = 2 | |
8 | 9 | ||
9 | - | ||
10 | + | let VOTING = "voting" | |
10 | 11 | ||
12 | + | let REVEAL = "reveal" | |
11 | 13 | ||
12 | - | ||
14 | + | let FEATURED = "featured" | |
13 | 15 | ||
16 | + | let DELISTED = "delisted" | |
14 | 17 | ||
15 | 18 | func getStrByKey (key) = { | |
16 | 19 | let str = match getString(this, key) { | |
17 | 20 | case a: String => | |
18 | 21 | a | |
19 | 22 | case _ => | |
20 | 23 | NONE | |
21 | 24 | } | |
22 | 25 | str | |
23 | 26 | } | |
24 | 27 | ||
25 | 28 | ||
26 | - | func getKeyItem (supp,title) = ("item_" + toBase58String(sha256(toBytes((supp + title))))) | |
27 | - | ||
28 | - | ||
29 | - | func getValueItemSupp (item) = getStrByKey(getKeyItemSupp(item)) | |
30 | - | ||
31 | - | ||
32 | 29 | func getNumberByKey (key) = { | |
33 | 30 | let num = match getInteger(this, key) { | |
34 | 31 | case a: Int => | |
35 | 32 | a | |
36 | 33 | case _ => | |
37 | 34 | 0 | |
38 | 35 | } | |
39 | 36 | num | |
40 | 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 + "_comcnt") | |
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)) | |
68 | + | ||
69 | + | ||
70 | + | func getKeyItemPrice (item) = (item + "_price") | |
71 | + | ||
72 | + | ||
73 | + | func getKeyItemData (item) = (item + "_data") | |
74 | + | ||
75 | + | ||
76 | + | func getKeyItemSupp (item) = (item + "_owner") | |
77 | + | ||
78 | + | ||
79 | + | func getKeyItem (supp,title) = ("item_" + toBase58String(sha256(toBytes((supp + title))))) | |
80 | + | ||
81 | + | ||
82 | + | func getValueItemSupp (item) = getStrByKey(getKeyItemSupp(item)) | |
41 | 83 | ||
42 | 84 | ||
43 | 85 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
44 | 86 | ||
45 | 87 | ||
46 | 88 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
47 | 89 | ||
48 | 90 | ||
49 | 91 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
50 | 92 | ||
51 | 93 | ||
52 | 94 | func getKeySuppBalance (supp) = (supp + "_balance") | |
53 | 95 | ||
54 | 96 | ||
55 | 97 | func getValueSuppBalance (supp) = getNumberByKey(getKeySuppBalance(supp)) | |
56 | 98 | ||
57 | 99 | ||
58 | 100 | @Callable(i) | |
59 | - | func withdraw () = { | |
60 | - | let suppAdr = toBase58String(i.caller.bytes) | |
61 | - | let balance = getValueSuppBalance(suppAdr) | |
62 | - | if ((0 >= balance)) | |
63 | - | then throw("insufficient balance") | |
64 | - | else ScriptResult(WriteSet([DataEntry(getKeySuppBalance(suppAdr), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppAdr), 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("reahced max voters") | |
107 | + | else if ((getValueCommit(item, user) != NONE)) | |
108 | + | then throw("user already voted") | |
109 | + | else if ((getKeyItemSupp(item) == NONE)) | |
110 | + | then throw("item does not exist") | |
111 | + | else if (if ((status != NONE)) | |
112 | + | then (status != VOTING) | |
113 | + | else false) | |
114 | + | then throw("vote is not possible") | |
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)]) | |
65 | 118 | } | |
66 | 119 | ||
67 | 120 |
github/deemru/w8io/169f3d6 47.73 ms ◑