tx · 8zETtHEGFeQC7sj9BVa8oWJXRAake1TwX9zFQgnECrps 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu: -0.01400000 Waves 2020.09.12 14:16 [1174032] smart account 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu > SELF 0.00000000 Waves
{ "type": 13, "id": "8zETtHEGFeQC7sj9BVa8oWJXRAake1TwX9zFQgnECrps", "fee": 1400000, "feeAssetId": null, "timestamp": 1599909400253, "version": 2, "chainId": 84, "sender": "3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu", "senderPublicKey": "CBTEuFN6ku1LNaPuGHHTMh2CBb3kPa5D73XXTJvKydun", "proofs": [ "3N8nV7cL5UK15hs2jpCmkhGoqsxnuhEF3g3qSbr4SBumYUVByhJRQcKdNRZKJEz9dP73KhPQ44YJgFK4CNe7pQtk" ], "script": "base64:AAIDAAAAAAAAACAIARIHCgUICAgICBIECgIICBIDCgEIEgMKAQgSAwoBCAAAAA8AAAAABnVwVm90ZQIAAAAGdXB2b3RlAAAAAA1hZG1pbkFkZHJlc3MxAQAAABoBVDi2IViANlgIPSCUAVQpoGSXhJ2Tw/Y0iwAAAAANYWRtaW5BZGRyZXNzMgEAAAAaAVTlj1A9878YQ058BBZUI9QC+LwgFva37DoAAAAADWFkbWluQWRkcmVzczMBAAAAGgFUrs609CRmf+XvZDjrx5XoefavLLpzyJEYAAAAAAVkeXpJZAEAAAAgfqtB2c5SyrdhjTSeT2NUMvY45D97zjqBcAiarzFPFmsBAAAADWdldFByb2ZpbGVLZXkAAAABAAAAAmlkCQABLAAAAAIFAAAAAmlkAgAAABRfZW50cmVwcmVuZXVyUHJvZmlsZQEAAAAMZ2V0U3RhdHVzS2V5AAAAAQAAAAJpZAkAASwAAAACBQAAAAJpZAIAAAAHX3N0YXR1cwEAAAARZ2V0Vm90ZXJBbW91bnRLZXkAAAACAAAAAmlkAAAABnZvdGVJZAkAASwAAAACCQABLAAAAAIJAAEsAAAAAgUAAAACaWQCAAAAAV8FA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WF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQkAAAIAAAABAgAAACVZb3UgZGlkbid0IHZvdGUgZm9yIHRoaXMgZW50cmVwcmVuZXVyAwkAAAAAAAACBQAAAA1jdXJyZW50QW1vdW50AAAAAAAAAAAACQAAAgAAAAECAAAAJFNlZW1zIHlvdSBoYXZlIHByZXZpb3VzbHkgd2l0aGRyYXduLgkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACmN1cnJlbnRLZXkAAAAAAAAAAAAFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAADWN1cnJlbnRBbW91bnQFAAAABWR5eklkBQAAAANuaWwJAAACAAAAAQIAAAA2Q2FuJ3Qgd2l0aGRyYXcgdm90ZSBhbW91bnQgd2hpbGUgdm90aW5nIGlzIHN0aWxsIG9wZW4uCQAAAgAAAAECAAAAJVlvdSBkaWRuJ3Qgdm90ZSBmb3IgdGhpcyBlbnRyZXByZW5ldXIAAAAAp6muOw==", "height": 1174032, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: C7WcVVowR6tq4aiRVXHGkRjuMDfbqf8DoEQtW6iPDXLF Next: E4aoksrWnw8boxv9HHcMfHyseXHTXVpm2VcnyJ1t94db Diff:
Old | New | Differences | |
---|---|---|---|
69 | 69 | ||
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | - | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if (if (if ((i.caller.bytes | |
72 | + | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if (if (if ((i.caller.bytes == adminAddress1)) | |
73 | 73 | then true | |
74 | - | else (i.caller.bytes | |
74 | + | else (i.caller.bytes == adminAddress2)) | |
75 | 75 | then true | |
76 | - | else (i.caller.bytes != adminAddress3)) | |
77 | - | then throw("Only Dyzrupt Admin can call this dApp function") | |
78 | - | else { | |
76 | + | else (i.caller.bytes == adminAddress3)) | |
77 | + | then { | |
79 | 78 | let transactionId = toBase58String(i.transactionId) | |
80 | 79 | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open")]) | |
81 | 80 | } | |
81 | + | else throw("Only Dyzrupt Admin can call this dApp function") | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | @Callable(i) | |
111 | - | func openVote (voteId) = if (if (if ((i.caller.bytes | |
111 | + | func openVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
112 | 112 | then true | |
113 | - | else (i.caller.bytes | |
113 | + | else (i.caller.bytes == adminAddress2)) | |
114 | 114 | then true | |
115 | - | else (i.caller.bytes != adminAddress3)) | |
116 | - | then throw("Only Dyzrupt Admin can call this dApp function") | |
117 | - | else if (profileExist(voteId)) | |
115 | + | else (i.caller.bytes == adminAddress3)) | |
116 | + | then if (profileExist(voteId)) | |
118 | 117 | then WriteSet([DataEntry(getStatusKey(voteId), "open")]) | |
119 | 118 | else throw("Invalid ID") | |
119 | + | else throw("Only Dyzrupt Admin can call this dApp function") | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | 123 | @Callable(i) | |
124 | - | func closeVote (voteId) = if (if (if ((i.caller.bytes | |
124 | + | func closeVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
125 | 125 | then true | |
126 | - | else (i.caller.bytes | |
126 | + | else (i.caller.bytes == adminAddress2)) | |
127 | 127 | then true | |
128 | - | else (i.caller.bytes != adminAddress3)) | |
129 | - | then throw("Only Dyzrupt Admin can call this dApp function") | |
130 | - | else if (profileExist(voteId)) | |
128 | + | else (i.caller.bytes == adminAddress3)) | |
129 | + | then if (profileExist(voteId)) | |
131 | 130 | then WriteSet([DataEntry(getStatusKey(voteId), "closed")]) | |
132 | 131 | else throw("Invalid ID") | |
132 | + | else throw("Only Dyzrupt Admin can call this dApp function") | |
133 | 133 | ||
134 | 134 | ||
135 | 135 |
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 adminAddress1 = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC' | |
7 | 7 | ||
8 | 8 | let adminAddress2 = base58'3NAqtCScgFynCuRLUoXm2BHTdu8suatCe7b' | |
9 | 9 | ||
10 | 10 | let adminAddress3 = base58'3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu' | |
11 | 11 | ||
12 | 12 | let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G' | |
13 | 13 | ||
14 | 14 | func getProfileKey (id) = (id + "_entrepreneurProfile") | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getStatusKey (id) = (id + "_status") | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getVoterAmountKey (id,voteId) = (((id + "_") + voteId) + "_amount") | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func getVoteKey (id,type) = if ((type == "upvote")) | |
24 | 24 | then (id + "_upvote") | |
25 | 25 | else throw("Invalid vote type") | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func profileExist (id) = match getString(this, getProfileKey(id)) { | |
29 | 29 | case a: String => | |
30 | 30 | true | |
31 | 31 | case _ => | |
32 | 32 | false | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getVoteStatus (voteId) = match getString(this, getStatusKey(voteId)) { | |
37 | 37 | case a: String => | |
38 | 38 | a | |
39 | 39 | case _ => | |
40 | 40 | false | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func getVoteCount (voteId,vote) = match getInteger(this, getVoteKey(voteId, vote)) { | |
45 | 45 | case a: Int => | |
46 | 46 | a | |
47 | 47 | case _ => | |
48 | 48 | throw("Not a valid vote ID") | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func getVoterKey (address,voteId) = ((((address + "_") + voteId) + "_") + "vote") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getVoter (address,voteId) = match getString(this, getVoterKey(address, voteId)) { | |
56 | 56 | case a: String => | |
57 | 57 | a | |
58 | 58 | case _ => | |
59 | 59 | "" | |
60 | 60 | } | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func canVote (address,voteId) = { | |
64 | 64 | let voter = getVoter(address, voteId) | |
65 | 65 | if ((voter == "")) | |
66 | 66 | then true | |
67 | 67 | else false | |
68 | 68 | } | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | - | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if (if (if ((i.caller.bytes | |
72 | + | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if (if (if ((i.caller.bytes == adminAddress1)) | |
73 | 73 | then true | |
74 | - | else (i.caller.bytes | |
74 | + | else (i.caller.bytes == adminAddress2)) | |
75 | 75 | then true | |
76 | - | else (i.caller.bytes != adminAddress3)) | |
77 | - | then throw("Only Dyzrupt Admin can call this dApp function") | |
78 | - | else { | |
76 | + | else (i.caller.bytes == adminAddress3)) | |
77 | + | then { | |
79 | 78 | let transactionId = toBase58String(i.transactionId) | |
80 | 79 | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open")]) | |
81 | 80 | } | |
81 | + | else throw("Only Dyzrupt Admin can call this dApp function") | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | 85 | @Callable(i) | |
86 | 86 | func vote (voteId,vote) = { | |
87 | 87 | let pmt = extract(i.payment) | |
88 | 88 | let voter = toBase58String(i.caller.bytes) | |
89 | 89 | if ((pmt.amount == 0)) | |
90 | 90 | then throw("You cannot vote without paying voting fee") | |
91 | 91 | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
92 | 92 | then throw("You can only vote with DYZRUPT token") | |
93 | 93 | else if (canVote(voter, voteId)) | |
94 | 94 | then if (profileExist(voteId)) | |
95 | 95 | then if ((getVoteStatus(voteId) == "open")) | |
96 | 96 | then if ((vote == upVote)) | |
97 | 97 | then { | |
98 | 98 | let voteCount = getVoteCount(voteId, vote) | |
99 | 99 | let newVoteCount = (voteCount + 1) | |
100 | 100 | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(voter, voteId), voteId), DataEntry(getVoterAmountKey(voter, voteId), pmt.amount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
101 | 101 | } | |
102 | 102 | else throw("Not a valid vote value") | |
103 | 103 | else throw("This profile is not open for voting") | |
104 | 104 | else throw("Invalid Profile") | |
105 | 105 | else throw("You can't vote twice") | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | @Callable(i) | |
111 | - | func openVote (voteId) = if (if (if ((i.caller.bytes | |
111 | + | func openVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
112 | 112 | then true | |
113 | - | else (i.caller.bytes | |
113 | + | else (i.caller.bytes == adminAddress2)) | |
114 | 114 | then true | |
115 | - | else (i.caller.bytes != adminAddress3)) | |
116 | - | then throw("Only Dyzrupt Admin can call this dApp function") | |
117 | - | else if (profileExist(voteId)) | |
115 | + | else (i.caller.bytes == adminAddress3)) | |
116 | + | then if (profileExist(voteId)) | |
118 | 117 | then WriteSet([DataEntry(getStatusKey(voteId), "open")]) | |
119 | 118 | else throw("Invalid ID") | |
119 | + | else throw("Only Dyzrupt Admin can call this dApp function") | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | 123 | @Callable(i) | |
124 | - | func closeVote (voteId) = if (if (if ((i.caller.bytes | |
124 | + | func closeVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
125 | 125 | then true | |
126 | - | else (i.caller.bytes | |
126 | + | else (i.caller.bytes == adminAddress2)) | |
127 | 127 | then true | |
128 | - | else (i.caller.bytes != adminAddress3)) | |
129 | - | then throw("Only Dyzrupt Admin can call this dApp function") | |
130 | - | else if (profileExist(voteId)) | |
128 | + | else (i.caller.bytes == adminAddress3)) | |
129 | + | then if (profileExist(voteId)) | |
131 | 130 | then WriteSet([DataEntry(getStatusKey(voteId), "closed")]) | |
132 | 131 | else throw("Invalid ID") | |
132 | + | else throw("Only Dyzrupt Admin can call this dApp function") | |
133 | 133 | ||
134 | 134 | ||
135 | 135 | ||
136 | 136 | @Callable(i) | |
137 | 137 | func withdraw (voteId) = { | |
138 | 138 | let voter = toBase58String(i.caller.bytes) | |
139 | 139 | if ((getVoter(voter, voteId) != "")) | |
140 | 140 | then if ((getVoteStatus(voteId) == "closed")) | |
141 | 141 | then { | |
142 | 142 | let currentKey = getVoterAmountKey(voter, voteId) | |
143 | 143 | let currentAmount = match getInteger(this, currentKey) { | |
144 | 144 | case a: Int => | |
145 | 145 | a | |
146 | 146 | case _ => | |
147 | 147 | throw("You didn't vote for this entrepreneur") | |
148 | 148 | } | |
149 | 149 | if ((currentAmount == 0)) | |
150 | 150 | then throw("Seems you have previously withdrawn.") | |
151 | 151 | else ScriptResult(WriteSet([DataEntry(currentKey, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, dyzId)])) | |
152 | 152 | } | |
153 | 153 | else throw("Can't withdraw vote amount while voting is still open.") | |
154 | 154 | else throw("You didn't vote for this entrepreneur") | |
155 | 155 | } | |
156 | 156 | ||
157 | 157 |
github/deemru/w8io/026f985 31.61 ms ◑