tx · Eu4ZUxXSzux8gxzQ5NgSd9Q2fsroLQcUNT2UPQ8QUbG4

3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu:  -0.01400000 Waves

2020.09.11 16:53 [1172735] smart account 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu > SELF 0.00000000 Waves

{ "type": 13, "id": "Eu4ZUxXSzux8gxzQ5NgSd9Q2fsroLQcUNT2UPQ8QUbG4", "fee": 1400000, "feeAssetId": null, "timestamp": 1599832459417, "version": 2, "chainId": 84, "sender": "3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu", "senderPublicKey": "CBTEuFN6ku1LNaPuGHHTMh2CBb3kPa5D73XXTJvKydun", "proofs": [ "3qrpxDVqq4iXZHBsxfG89Rk4zx3VtCD3HuMec134K8Eu3Ba8hysX39pKJU3jAF8DQ7orJbSXy2NLhe8GFxwLXpaF" ], "script": "base64:AAIDAAAAAAAAACAIARIHCgUICAgICBIECgIICBIDCgEIEgMKAQgSAwoBCAAAAA0AAAAABnVwVm90ZQIAAAAGdXB2b3RlAAAAAAxhZG1pbkFkZHJlc3MBAAAAGgFUOLYhWIA2WAg9IJQBVCmgZJeEnZPD9jSLAAAAAAVkeXpJZAEAAAAgfqtB2c5SyrdhjTSeT2NUMvY45D97zjqBcAiarzFPFmsBAAAADWdldFByb2ZpbGVLZXkAAAABAAAAAmlkCQABLAAAAAIFAAAAAmlkAgAAABRfZW50cmVwcmVuZXVyUHJvZmlsZQEAAAAMZ2V0U3RhdHVzS2V5AAAAAQAAAAJpZAkAASwAAAACBQAAAAJpZAIAAAAHX3N0YXR1cwEAAAARZ2V0Vm90ZXJBbW91bnRLZXkAAAACAAAAAmlkAAAABnZvdGVJZAkAASwAAAACCQABLAAAAAIJAAEsAAAAAgUAAAACaWQCAAAAAV8FAAAABnZvdGVJZAIAAAAHX2Ftb3VudAEAAAAKZ2V0Vm90ZUtleQAAAAIAAAACaWQAAAAEdHlwZQMJAAAAAAAAAgUAAAAEdHlwZQIAAAAG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XIFAAAADWN1cnJlbnRBbW91bnQFAAAABWR5eklkBQAAAANuaWwJAAACAAAAAQIAAAA2Q2FuJ3Qgd2l0aGRyYXcgdm90ZSBhbW91bnQgd2hpbGUgdm90aW5nIGlzIHN0aWxsIG9wZW4uCQAAAgAAAAECAAAAJVlvdSBkaWRuJ3Qgdm90ZSBmb3IgdGhpcyBlbnRyZXByZW5ldXIAAAAAcCdywA==", "height": 1172735, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6fefZLiPHpWLS8x1Q8epL6WFoW7Bv1DKzBf8E7zJZTyv Next: C7WcVVowR6tq4aiRVXHGkRjuMDfbqf8DoEQtW6iPDXLF Diff:
OldNewDifferences
1111
1212
1313 func getStatusKey (id) = (id + "_status")
14+
15+
16+func getVoterAmountKey (id,voteId) = (((id + "_") + voteId) + "_amount")
1417
1518
1619 func getVoteKey (id,type) = if ((type == "upvote"))
7477 @Callable(i)
7578 func vote (voteId,vote) = {
7679 let pmt = extract(i.payment)
80+ let voter = toBase58String(i.caller.bytes)
7781 if ((pmt.amount == 0))
7882 then throw("You cannot vote without paying voting fee")
7983 else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G'))
8084 then throw("You can only vote with DYZRUPT token")
81- else if (canVote(toBase58String(i.caller.bytes), voteId))
85+ else if (canVote(voter, voteId))
8286 then if (profileExist(voteId))
8387 then if ((getVoteStatus(voteId) == "open"))
8488 then if ((vote == upVote))
8589 then {
8690 let voteCount = getVoteCount(voteId, vote)
8791 let newVoteCount = (voteCount + 1)
88- ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)]))
92+ ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(voter, voteId), voteId), DataEntry(getVoterAmountKey(voter, voteId), pmt.amount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)]))
8993 }
9094 else throw("Not a valid vote value")
9195 else throw("This profile is not open for voting")
112116 else throw("Invalid ID")
113117
114118
119+
120+@Callable(i)
121+func withdraw (voteId) = {
122+ let voter = toBase58String(i.caller.bytes)
123+ if ((getVoter(voter, voteId) != ""))
124+ then if ((getVoteStatus(voteId) == "closed"))
125+ then {
126+ let currentKey = getVoterAmountKey(voter, voteId)
127+ let currentAmount = match getInteger(this, currentKey) {
128+ case a: Int =>
129+ a
130+ case _ =>
131+ throw("You didn't vote for this entrepreneur")
132+ }
133+ if ((currentAmount == 0))
134+ then throw("Seems you have previously withdrawn.")
135+ else ScriptResult(WriteSet([DataEntry(currentKey, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, dyzId)]))
136+ }
137+ else throw("Can't withdraw vote amount while voting is still open.")
138+ else throw("You didn't vote for this entrepreneur")
139+ }
140+
141+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let upVote = "upvote"
55
66 let adminAddress = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC'
77
88 let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G'
99
1010 func getProfileKey (id) = (id + "_entrepreneurProfile")
1111
1212
1313 func getStatusKey (id) = (id + "_status")
14+
15+
16+func getVoterAmountKey (id,voteId) = (((id + "_") + voteId) + "_amount")
1417
1518
1619 func getVoteKey (id,type) = if ((type == "upvote"))
1720 then (id + "_upvote")
1821 else throw("Invalid vote type")
1922
2023
2124 func profileExist (id) = match getString(this, getProfileKey(id)) {
2225 case a: String =>
2326 true
2427 case _ =>
2528 false
2629 }
2730
2831
2932 func getVoteStatus (voteId) = match getString(this, getStatusKey(voteId)) {
3033 case a: String =>
3134 a
3235 case _ =>
3336 false
3437 }
3538
3639
3740 func getVoteCount (voteId,vote) = match getInteger(this, getVoteKey(voteId, vote)) {
3841 case a: Int =>
3942 a
4043 case _ =>
4144 throw("Not a valid vote ID")
4245 }
4346
4447
4548 func getVoterKey (address,voteId) = ((((address + "_") + voteId) + "_") + "vote")
4649
4750
4851 func getVoter (address,voteId) = match getString(this, getVoterKey(address, voteId)) {
4952 case a: String =>
5053 a
5154 case _ =>
5255 ""
5356 }
5457
5558
5659 func canVote (address,voteId) = {
5760 let voter = getVoter(address, voteId)
5861 if ((voter == ""))
5962 then true
6063 else false
6164 }
6265
6366
6467 @Callable(i)
6568 func addEntrepreneurProfile (name,avatar,bio,gender,location) = if ((i.caller.bytes != adminAddress))
6669 then throw("Only Dyzrupt Admin can call this dApp function")
6770 else {
6871 let transactionId = toBase58String(i.transactionId)
6972 WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open")])
7073 }
7174
7275
7376
7477 @Callable(i)
7578 func vote (voteId,vote) = {
7679 let pmt = extract(i.payment)
80+ let voter = toBase58String(i.caller.bytes)
7781 if ((pmt.amount == 0))
7882 then throw("You cannot vote without paying voting fee")
7983 else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G'))
8084 then throw("You can only vote with DYZRUPT token")
81- else if (canVote(toBase58String(i.caller.bytes), voteId))
85+ else if (canVote(voter, voteId))
8286 then if (profileExist(voteId))
8387 then if ((getVoteStatus(voteId) == "open"))
8488 then if ((vote == upVote))
8589 then {
8690 let voteCount = getVoteCount(voteId, vote)
8791 let newVoteCount = (voteCount + 1)
88- ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)]))
92+ ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(voter, voteId), voteId), DataEntry(getVoterAmountKey(voter, voteId), pmt.amount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)]))
8993 }
9094 else throw("Not a valid vote value")
9195 else throw("This profile is not open for voting")
9296 else throw("Invalid Profile")
9397 else throw("You can't vote twice")
9498 }
9599
96100
97101
98102 @Callable(i)
99103 func openVote (voteId) = if ((i.caller.bytes != adminAddress))
100104 then throw("Only Dyzrupt Admin can call this dApp function")
101105 else if (profileExist(voteId))
102106 then WriteSet([DataEntry(getStatusKey(voteId), "open")])
103107 else throw("Invalid ID")
104108
105109
106110
107111 @Callable(i)
108112 func closeVote (voteId) = if ((i.caller.bytes != adminAddress))
109113 then throw("Only Dyzrupt Admin can call this dApp function")
110114 else if (profileExist(voteId))
111115 then WriteSet([DataEntry(getStatusKey(voteId), "closed")])
112116 else throw("Invalid ID")
113117
114118
119+
120+@Callable(i)
121+func withdraw (voteId) = {
122+ let voter = toBase58String(i.caller.bytes)
123+ if ((getVoter(voter, voteId) != ""))
124+ then if ((getVoteStatus(voteId) == "closed"))
125+ then {
126+ let currentKey = getVoterAmountKey(voter, voteId)
127+ let currentAmount = match getInteger(this, currentKey) {
128+ case a: Int =>
129+ a
130+ case _ =>
131+ throw("You didn't vote for this entrepreneur")
132+ }
133+ if ((currentAmount == 0))
134+ then throw("Seems you have previously withdrawn.")
135+ else ScriptResult(WriteSet([DataEntry(currentKey, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, dyzId)]))
136+ }
137+ else throw("Can't withdraw vote amount while voting is still open.")
138+ else throw("You didn't vote for this entrepreneur")
139+ }
140+
141+

github/deemru/w8io/026f985 
32.78 ms