tx · 6fcRYCzvb6mLmjpGTEqqzn7ZXpaJQ5WcCUzG57Z3T8o9 3MriS1yLhFcKRAM51jDyNAdusa6bCWrTCYj: -0.01000000 Waves 2024.02.06 12:14 [2964193] smart account 3MriS1yLhFcKRAM51jDyNAdusa6bCWrTCYj > SELF 0.00000000 Waves
{ "type": 13, "id": "6fcRYCzvb6mLmjpGTEqqzn7ZXpaJQ5WcCUzG57Z3T8o9", "fee": 1000000, "feeAssetId": null, "timestamp": 1707210927156, "version": 2, "chainId": 84, "sender": "3MriS1yLhFcKRAM51jDyNAdusa6bCWrTCYj", "senderPublicKey": "CgjXoHPsstPW1WBAcTeBgjKtLSNFmLbQ7pLJ19JzkCy9", "proofs": [ "4MPX6D96zY4cC9joAwuiRWviPPo5jdAFTQiwtcr3RAL4dhq7mEDgwoua6bJ46JMmurK1FWatD1bphDXrbht6x3TM" ], "script": "base64:AAIFAAAAAAAAABgIAhIFCgMICAgSAwoBCBIDCgEIEgMKAQgAAAAFAAAAAA9tYWluREFPQ29udHJhY3QJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAECAAAAIzNOOXRLaXh6cVRZV25FWFF4ckRRNXBCVEd2UWQ2c0Zzdm1WAQAAABJnZXRWb3Rlc0Zyb21DYWxsZXIAAAABAAAACXB1YmxpY0tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAA9tYWluREFPQ29udHJhY3QJAAEsAAAAAgIAAAAJZGFvX3VzZXJfBQAAAAlwdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABaQUAAAAHJG1hdGNoMAUAAAABaQD//////////wEAAAAPZ2V0QWxyZWFkeVZvdGVkAAAAAgAAAAZ2b3RlSWQAAAAJcHVibGljS2V5BAAAAAckbWF0Y2gwCQAEGwAAAAIFAAAABHRoaXMJAAEsAAAAAgkAASwAAAACCQABLAAAAAIFAAAABnZvdGVJZAIAAAABXwUAAAAJcHVibGljS2V5AgAAAAZfdm90ZWQDCQA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AACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkAASwAAAACBQAAAAZ2b3RlSWQCAAAABF95ZXMJAABlAAAAAgUAAAAPY3VycmVudFllc1ZvdGVzBQAAABJ5ZXNWb3Rlc0Zyb21DYWxsZXIJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIFAAAABnZvdGVJZAIAAAABXwUAAAAPY2FsbGVyUHVibGljS2V5AgAAAANfbm8AAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIFAAAABnZvdGVJZAIAAAABXwUAAAAPY2FsbGVyUHVibGljS2V5AgAAAARfeWVzAAAAAAAAAAAACQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAZ2b3RlSWQCAAAAAV8FAAAAD2NhbGxlclB1YmxpY0tleQIAAAAGX3ZvdGVkBwUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmqVIZK", "height": 2964193, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 9WTWmrDj3xHekfa78f7sHmGLo7nPf5iyLiRKqVCabkvy Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let mainDAOContract = addressFromStringValue("3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV") | |
5 | + | ||
6 | + | func getVotesFromCaller (publicKey) = match getInteger(mainDAOContract, ("dao_user_" + publicKey)) { | |
7 | + | case i: Int => | |
8 | + | i | |
9 | + | case _ => | |
10 | + | -1 | |
11 | + | } | |
12 | + | ||
13 | + | ||
14 | + | func getAlreadyVoted (voteId,publicKey) = match getBoolean(this, (((voteId + "_") + publicKey) + "_voted")) { | |
15 | + | case b: Boolean => | |
16 | + | b | |
17 | + | case _ => | |
18 | + | false | |
19 | + | } | |
20 | + | ||
21 | + | ||
22 | + | func getCurrentYesVotesForId (voteId) = match getInteger(this, (voteId + "_yes")) { | |
23 | + | case i: Int => | |
24 | + | i | |
25 | + | case _ => | |
26 | + | -1 | |
27 | + | } | |
28 | + | ||
29 | + | ||
30 | + | func getCurrentNoVotesForId (voteId) = match getInteger(this, (voteId + "_no")) { | |
31 | + | case i: Int => | |
32 | + | i | |
33 | + | case _ => | |
34 | + | -1 | |
35 | + | } | |
36 | + | ||
37 | + | ||
38 | + | @Callable(i) | |
39 | + | func registerVote (title,desc,link) = { | |
40 | + | let voteId = toBase58String(i.transactionId) | |
41 | + | let endBlock = (height + 7200) | |
42 | + | [IntegerEntry((voteId + "_endHeight"), endBlock), StringEntry((voteId + "_title"), title), StringEntry((voteId + "_description"), desc), StringEntry((voteId + "_link"), link), IntegerEntry((voteId + "_yes"), 0), IntegerEntry((voteId + "_no"), 0)] | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | ||
47 | + | @Callable(i) | |
48 | + | func yes (voteId) = { | |
49 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
50 | + | let currentYesVotes = getCurrentYesVotesForId(voteId) | |
51 | + | let votesFromCaller = getVotesFromCaller(callerPublicKey) | |
52 | + | let alreadyVoted = getAlreadyVoted(voteId, callerPublicKey) | |
53 | + | if ((currentYesVotes == -1)) | |
54 | + | then throw("Vote not found!") | |
55 | + | else if (alreadyVoted) | |
56 | + | then throw("Address already voted!") | |
57 | + | else [IntegerEntry((voteId + "_yes"), (currentYesVotes + votesFromCaller)), IntegerEntry((((voteId + "_") + callerPublicKey) + "_yes"), votesFromCaller), BooleanEntry((((voteId + "_") + callerPublicKey) + "_voted"), true)] | |
58 | + | } | |
59 | + | ||
60 | + | ||
61 | + | ||
62 | + | @Callable(i) | |
63 | + | func no (voteId) = { | |
64 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
65 | + | let currentNoVotes = getCurrentNoVotesForId(voteId) | |
66 | + | let votesFromCaller = getVotesFromCaller(callerPublicKey) | |
67 | + | let alreadyVoted = getAlreadyVoted(voteId, callerPublicKey) | |
68 | + | if ((currentNoVotes == -1)) | |
69 | + | then throw("Vote not found!") | |
70 | + | else if (alreadyVoted) | |
71 | + | then throw("Address already voted!") | |
72 | + | else [IntegerEntry((voteId + "_no"), (currentNoVotes + votesFromCaller)), IntegerEntry((((voteId + "_") + callerPublicKey) + "_no"), votesFromCaller), BooleanEntry((((voteId + "_") + callerPublicKey) + "_voted"), true)] | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | @Callable(i) | |
78 | + | func retractVote (voteId) = { | |
79 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
80 | + | let currentNoVotes = getCurrentNoVotesForId(voteId) | |
81 | + | let currentYesVotes = getCurrentYesVotesForId(voteId) | |
82 | + | let noVotesFromCaller = match getInteger(this, (((voteId + "_") + callerPublicKey) + "_no")) { | |
83 | + | case n: Int => | |
84 | + | n | |
85 | + | case _ => | |
86 | + | 0 | |
87 | + | } | |
88 | + | let yesVotesFromCaller = match getInteger(this, (((voteId + "_") + callerPublicKey) + "_yes")) { | |
89 | + | case n: Int => | |
90 | + | n | |
91 | + | case _ => | |
92 | + | 0 | |
93 | + | } | |
94 | + | if (if ((currentYesVotes == -1)) | |
95 | + | then true | |
96 | + | else (currentNoVotes == -1)) | |
97 | + | then throw("No active vote for this vote id!") | |
98 | + | else [IntegerEntry((voteId + "_no"), (currentNoVotes - noVotesFromCaller)), IntegerEntry((voteId + "_yes"), (currentYesVotes - yesVotesFromCaller)), IntegerEntry((((voteId + "_") + callerPublicKey) + "_no"), 0), IntegerEntry((((voteId + "_") + callerPublicKey) + "_yes"), 0), BooleanEntry((((voteId + "_") + callerPublicKey) + "_voted"), false)] | |
99 | + | } | |
100 | + | ||
101 | + | ||
102 | + | @Verifier(tx) | |
103 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
104 | + |
github/deemru/w8io/169f3d6 23.90 ms ◑