tx · Hee47hqHSerHkFYv38TzHviUUTXnxR8pze5pfAZz4927 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu: -0.01400000 Waves 2020.09.03 02:18 [1160424] smart account 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu > SELF 0.00000000 Waves
{ "type": 13, "id": "Hee47hqHSerHkFYv38TzHviUUTXnxR8pze5pfAZz4927", "fee": 1400000, "feeAssetId": null, "timestamp": 1599088704057, "version": 1, "sender": "3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu", "senderPublicKey": "CBTEuFN6ku1LNaPuGHHTMh2CBb3kPa5D73XXTJvKydun", "proofs": [ "5dkQntpBzgMEE7Q1xfFKbt6vLKfecos9pHNsA4UEhf6TjAz9F5ut4iX4L1A3iywiZdN7cM7q5N7MHYEXDQ8JBbgi" ], "script": "base64:AAIDAAAAAAAAABsIARIHCgUICAgICBIECgIICBIDCgEIEgMKAQgAAAANAAAAAAZ1cFZvdGUCAAAABnVwdm90ZQAAAAAIZG93blZvdGUCAAAACGRvd252b3RlAAAAAAxhZG1pbkFkZHJlc3MBAAAAGgFUOLYhWIA2WAg9IJQBVCmgZJeEnZPD9jSLAAAAAAVkeXpJZAEAAAAgfqtB2c5SyrdhjTSeT2NUMvY45D97zjqBcAiarzFPFmsBAAAADWdldFByb2ZpbGVLZXkAAAABAAAAAmlkCQABLAAAAAIFAAAAAmlkAgAAABRfZW50cmVwcmVuZXVyUHJvZmlsZQEAAAAMZ2V0U3RhdHVzS2V5AAAAAQAAAAJpZAkAASwAAAACBQAAAAJpZAIAAAAHX3N0YXR1cwEAAAAKZ2V0Vm90ZUtleQAAAAIAAAACaWQAAAAEdHlwZQMJAAAAAAAAAgUAAAAEdHlwZQIAAAAGdXB2b3RlCQABLAAAAAIFAAAAAmlkAgAAAAdfdXB2b3RlAwkAAAAAAAACBQAAAAR0eXBlAgAAAAhkb3dudm90ZQkAASwAAAACBQAAAAJpZAIAAAAJX2Rvd252b3RlCQAAAgAAAAECAAAAE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AkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAADGdldFN0YXR1c0tleQAAAAEFAAAABnZvdGVJZAIAAAAGY2xvc2VkBQAAAANuaWwJAAACAAAAAQIAAAAKSW52YWxpZCBJRAAAAACIRUyu", "chainId": 84, "height": 1160424, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9YWZEUdaZisAJ7AvsaToWskp7nGe4j4RcQqL5iih8Rjo Next: 6fefZLiPHpWLS8x1Q8epL6WFoW7Bv1DKzBf8E7zJZTyv Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let downVote = "downvote" | |
7 | 7 | ||
8 | 8 | let adminAddress = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC' | |
9 | + | ||
10 | + | let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G' | |
9 | 11 | ||
10 | 12 | func getProfileKey (id) = (id + "_entrepreneurProfile") | |
11 | 13 | ||
74 | 76 | ||
75 | 77 | ||
76 | 78 | @Callable(i) | |
77 | - | func vote (voteId,vote) = if (canVote(toBase58String(i.caller.bytes), voteId)) | |
78 | - | then if (profileExist(voteId)) | |
79 | - | then if ((getVoteStatus(voteId) == "open")) | |
80 | - | then if (if ((vote == upVote)) | |
81 | - | then true | |
82 | - | else (vote == downVote)) | |
83 | - | then { | |
84 | - | let voteCount = getVoteCount(voteId, vote) | |
85 | - | let newVoteCount = (voteCount + 1) | |
86 | - | WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]) | |
87 | - | } | |
88 | - | else throw("Not a valid vote value") | |
89 | - | else throw("This profile is not open for voting") | |
90 | - | else throw("Invalid Profile") | |
91 | - | else throw("You can't vote twice") | |
79 | + | func vote (voteId,vote) = { | |
80 | + | let pmt = extract(i.payment) | |
81 | + | if ((pmt.amount == 0)) | |
82 | + | then throw("You cannot vote without paying voting fee") | |
83 | + | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
84 | + | then throw("You can only vote with DYZRUPT token") | |
85 | + | else if (canVote(toBase58String(i.caller.bytes), voteId)) | |
86 | + | then if (profileExist(voteId)) | |
87 | + | then if ((getVoteStatus(voteId) == "open")) | |
88 | + | then if (if ((vote == upVote)) | |
89 | + | then true | |
90 | + | else (vote == downVote)) | |
91 | + | then { | |
92 | + | let voteCount = getVoteCount(voteId, vote) | |
93 | + | let newVoteCount = (voteCount + 1) | |
94 | + | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
95 | + | } | |
96 | + | else throw("Not a valid vote value") | |
97 | + | else throw("This profile is not open for voting") | |
98 | + | else throw("Invalid Profile") | |
99 | + | else throw("You can't vote twice") | |
100 | + | } | |
92 | 101 | ||
93 | 102 | ||
94 | 103 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let upVote = "upvote" | |
5 | 5 | ||
6 | 6 | let downVote = "downvote" | |
7 | 7 | ||
8 | 8 | let adminAddress = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC' | |
9 | + | ||
10 | + | let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G' | |
9 | 11 | ||
10 | 12 | func getProfileKey (id) = (id + "_entrepreneurProfile") | |
11 | 13 | ||
12 | 14 | ||
13 | 15 | func getStatusKey (id) = (id + "_status") | |
14 | 16 | ||
15 | 17 | ||
16 | 18 | func getVoteKey (id,type) = if ((type == "upvote")) | |
17 | 19 | then (id + "_upvote") | |
18 | 20 | else if ((type == "downvote")) | |
19 | 21 | then (id + "_downvote") | |
20 | 22 | else throw("Invalid vote type") | |
21 | 23 | ||
22 | 24 | ||
23 | 25 | func profileExist (id) = match getString(this, getProfileKey(id)) { | |
24 | 26 | case a: String => | |
25 | 27 | true | |
26 | 28 | case _ => | |
27 | 29 | false | |
28 | 30 | } | |
29 | 31 | ||
30 | 32 | ||
31 | 33 | func getVoteStatus (voteId) = match getString(this, getStatusKey(voteId)) { | |
32 | 34 | case a: String => | |
33 | 35 | a | |
34 | 36 | case _ => | |
35 | 37 | false | |
36 | 38 | } | |
37 | 39 | ||
38 | 40 | ||
39 | 41 | func getVoteCount (voteId,vote) = match getInteger(this, getVoteKey(voteId, vote)) { | |
40 | 42 | case a: Int => | |
41 | 43 | a | |
42 | 44 | case _ => | |
43 | 45 | throw("Not a valid vote ID") | |
44 | 46 | } | |
45 | 47 | ||
46 | 48 | ||
47 | 49 | func getVoterKey (address,voteId) = ((((address + "_") + voteId) + "_") + "vote") | |
48 | 50 | ||
49 | 51 | ||
50 | 52 | func getVoter (address,voteId) = match getString(this, getVoterKey(address, voteId)) { | |
51 | 53 | case a: String => | |
52 | 54 | a | |
53 | 55 | case _ => | |
54 | 56 | "" | |
55 | 57 | } | |
56 | 58 | ||
57 | 59 | ||
58 | 60 | func canVote (address,voteId) = { | |
59 | 61 | let voter = getVoter(address, voteId) | |
60 | 62 | if ((voter == "")) | |
61 | 63 | then true | |
62 | 64 | else false | |
63 | 65 | } | |
64 | 66 | ||
65 | 67 | ||
66 | 68 | @Callable(i) | |
67 | 69 | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if ((i.caller.bytes != adminAddress)) | |
68 | 70 | then throw("Only Dyzrupt Admin can call this dApp function") | |
69 | 71 | else { | |
70 | 72 | let transactionId = toBase58String(i.transactionId) | |
71 | 73 | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open"), DataEntry(getVoteKey(transactionId, "downvote"), 0)]) | |
72 | 74 | } | |
73 | 75 | ||
74 | 76 | ||
75 | 77 | ||
76 | 78 | @Callable(i) | |
77 | - | func vote (voteId,vote) = if (canVote(toBase58String(i.caller.bytes), voteId)) | |
78 | - | then if (profileExist(voteId)) | |
79 | - | then if ((getVoteStatus(voteId) == "open")) | |
80 | - | then if (if ((vote == upVote)) | |
81 | - | then true | |
82 | - | else (vote == downVote)) | |
83 | - | then { | |
84 | - | let voteCount = getVoteCount(voteId, vote) | |
85 | - | let newVoteCount = (voteCount + 1) | |
86 | - | WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]) | |
87 | - | } | |
88 | - | else throw("Not a valid vote value") | |
89 | - | else throw("This profile is not open for voting") | |
90 | - | else throw("Invalid Profile") | |
91 | - | else throw("You can't vote twice") | |
79 | + | func vote (voteId,vote) = { | |
80 | + | let pmt = extract(i.payment) | |
81 | + | if ((pmt.amount == 0)) | |
82 | + | then throw("You cannot vote without paying voting fee") | |
83 | + | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
84 | + | then throw("You can only vote with DYZRUPT token") | |
85 | + | else if (canVote(toBase58String(i.caller.bytes), voteId)) | |
86 | + | then if (profileExist(voteId)) | |
87 | + | then if ((getVoteStatus(voteId) == "open")) | |
88 | + | then if (if ((vote == upVote)) | |
89 | + | then true | |
90 | + | else (vote == downVote)) | |
91 | + | then { | |
92 | + | let voteCount = getVoteCount(voteId, vote) | |
93 | + | let newVoteCount = (voteCount + 1) | |
94 | + | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
95 | + | } | |
96 | + | else throw("Not a valid vote value") | |
97 | + | else throw("This profile is not open for voting") | |
98 | + | else throw("Invalid Profile") | |
99 | + | else throw("You can't vote twice") | |
100 | + | } | |
92 | 101 | ||
93 | 102 | ||
94 | 103 | ||
95 | 104 | @Callable(i) | |
96 | 105 | func openVote (voteId) = if ((i.caller.bytes != adminAddress)) | |
97 | 106 | then throw("Only Dyzrupt Admin can call this dApp function") | |
98 | 107 | else if (profileExist(voteId)) | |
99 | 108 | then WriteSet([DataEntry(getStatusKey(voteId), "open")]) | |
100 | 109 | else throw("Invalid ID") | |
101 | 110 | ||
102 | 111 | ||
103 | 112 | ||
104 | 113 | @Callable(i) | |
105 | 114 | func closeVote (voteId) = if ((i.caller.bytes != adminAddress)) | |
106 | 115 | then throw("Only Dyzrupt Admin can call this dApp function") | |
107 | 116 | else if (profileExist(voteId)) | |
108 | 117 | then WriteSet([DataEntry(getStatusKey(voteId), "closed")]) | |
109 | 118 | else throw("Invalid ID") | |
110 | 119 | ||
111 | 120 |
github/deemru/w8io/169f3d6 34.43 ms ◑