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