4 | | - | let A4AStakingDApp = addressFromStringValue("3N6oWLyQY2gM7QUkUvBme1REnA6d1V7y3AT") |
---|
5 | | - | |
---|
6 | | - | let voting_timestamp_controller_pubkey = base58'515tSAyMUbAb8kKjcpGDpqALGfCgcwfWmWKKkcBKTcGB' |
---|
7 | | - | |
---|
8 | | - | let controller_address = addressFromPublicKey(voting_timestamp_controller_pubkey) |
---|
9 | | - | |
---|
10 | | - | let launch_error = "Dapp will start Voting at Timestamp " |
---|
11 | | - | |
---|
12 | | - | let msg = "<h1>Your Vote Submitted Successfully!</h1><br>" |
---|
13 | | - | |
---|
14 | | - | let AlreadyVotedError = "This Address Already participated for Voting in this Proposal." |
---|
15 | | - | |
---|
16 | | - | let voteErr = "Voting is Over for this Dapp." |
---|
17 | | - | |
---|
18 | | - | @Callable(i) |
---|
19 | | - | func SetVotingTimeStamps (Proposal,Voting_Start_TimeStamp,Voting_End_TimeStamp) = { |
---|
20 | | - | let StartTS = Voting_Start_TimeStamp |
---|
21 | | - | let EndTS = Voting_End_TimeStamp |
---|
22 | | - | let readtotalStakedA4A = getIntegerValue(A4AStakingDApp, "Staked_Amount") |
---|
23 | | - | let QuorumValue = fraction(readtotalStakedA4A, 1, 3) |
---|
24 | | - | let pubkey = toBase58String(i.caller.bytes) |
---|
25 | | - | let Previoustotalproposals = match getInteger(this, "Total_Proposals") { |
---|
26 | | - | case a: Int => |
---|
27 | | - | a |
---|
28 | | - | case _ => |
---|
29 | | - | 0 |
---|
30 | | - | } |
---|
31 | | - | let totalproposals = (Previoustotalproposals + 1) |
---|
32 | | - | if ((size(Proposal) > 5100)) |
---|
33 | | - | then throw("Subject Char Limits are Over. Reduce length less than 5100 Char.") |
---|
34 | | - | else if ((i.caller != controller_address)) |
---|
35 | | - | then throw((("This Address is not Authorized. Only " + toString(controller_address)) + " is Authorized Address to Sign it.")) |
---|
36 | | - | else [StringEntry(("Proposal_Text_" + toString(totalproposals)), Proposal), IntegerEntry("Total_Proposals", totalproposals), StringEntry(("Proposer_" + toString(totalproposals)), pubkey), IntegerEntry(("Voting_Start_TimeStamp_" + toString(totalproposals)), StartTS), IntegerEntry(("Voting_End_TimeStamp_" + toString(totalproposals)), EndTS), IntegerEntry(("Minimum_Quorum_" + toString(totalproposals)), QuorumValue), IntegerEntry(("Total_Votes_" + toString(totalproposals)), 0), IntegerEntry(("Total_No_" + toString(totalproposals)), 0), IntegerEntry(("Total_Yes_" + toString(totalproposals)), 0), StringEntry(("Quorum_Status_" + toString(totalproposals)), "Fail")] |
---|
37 | | - | } |
---|
38 | | - | |
---|
42 | | - | func Yes (Porposal_ID) = { |
---|
43 | | - | let VoteAst = "Yes" |
---|
44 | | - | let StartTS = getIntegerValue(this, ("Voting_Start_TimeStamp_" + toString(Porposal_ID))) |
---|
45 | | - | let EndTS = getIntegerValue(this, ("Voting_End_TimeStamp_" + toString(Porposal_ID))) |
---|
46 | | - | let pubkey = toBase58String(i.caller.bytes) |
---|
47 | | - | let readA4AStakingAmount = valueOrErrorMessage(getInteger(A4AStakingDApp, ("Deposit_Amount_Of_" + pubkey)), "Address not found in A4A Staking.") |
---|
48 | | - | let readQuoraumValue = getIntegerValue(this, ("Minimum_Quorum_" + toString(Porposal_ID))) |
---|
49 | | - | let Previoustotalvotes = match getInteger(this, ("Total_Votes_" + toString(Porposal_ID))) { |
---|
50 | | - | case a: Int => |
---|
51 | | - | a |
---|
52 | | - | case _ => |
---|
53 | | - | 0 |
---|
54 | | - | } |
---|
55 | | - | let totalvotes = (Previoustotalvotes + readA4AStakingAmount) |
---|
56 | | - | let FTVO = match getInteger(this, ((("Total_" + VoteAst) + "_") + toString(Porposal_ID))) { |
---|
57 | | - | case a: Int => |
---|
58 | | - | a |
---|
59 | | - | case _ => |
---|
60 | | - | 0 |
---|
61 | | - | } |
---|
62 | | - | let ATVO = (FTVO + readA4AStakingAmount) |
---|
63 | | - | let PreviousUserCountforVoting = match getInteger(this, ((pubkey + "_") + toString(Porposal_ID))) { |
---|
64 | | - | case a: Int => |
---|
65 | | - | a |
---|
66 | | - | case _ => |
---|
67 | | - | 0 |
---|
68 | | - | } |
---|
69 | | - | let LatestUserCountforVoting = (PreviousUserCountforVoting + 1) |
---|
70 | | - | if ((StartTS > lastBlock.timestamp)) |
---|
71 | | - | then throw((launch_error + toString(StartTS))) |
---|
72 | | - | else if ((lastBlock.timestamp > EndTS)) |
---|
73 | | - | then throw(voteErr) |
---|
74 | | - | else if ((readQuoraumValue > totalvotes)) |
---|
75 | | - | then [IntegerEntry(("Total_Votes_" + toString(Porposal_ID)), totalvotes), IntegerEntry(((("Total_" + VoteAst) + "_") + toString(Porposal_ID)), ATVO), IntegerEntry(((pubkey + "_") + toString(Porposal_ID)), LatestUserCountforVoting), StringEntry(("Quorum_Status_" + toString(Porposal_ID)), "Fail"), StringEntry("message", msg)] |
---|
76 | | - | else if ((totalvotes > readQuoraumValue)) |
---|
77 | | - | then [IntegerEntry(("Total_Votes_" + toString(Porposal_ID)), totalvotes), IntegerEntry(((("Total_" + VoteAst) + "_") + toString(Porposal_ID)), ATVO), IntegerEntry(((pubkey + "_") + toString(Porposal_ID)), LatestUserCountforVoting), StringEntry(("Quorum_Status_" + toString(Porposal_ID)), "Pass"), StringEntry("message", msg)] |
---|
78 | | - | else throw("Wrong Value Entered.") |
---|
79 | | - | } |
---|
| 7 | + | func Withdraw () = [ScriptTransfer(i.caller, 1000, unit)] |
---|
81 | | - | |
---|
82 | | - | |
---|
83 | | - | @Callable(i) |
---|
84 | | - | func No (Porposal_ID) = { |
---|
85 | | - | let VoteAst = "No" |
---|
86 | | - | let StartTS = getIntegerValue(this, ("Voting_Start_TimeStamp_" + toString(Porposal_ID))) |
---|
87 | | - | let EndTS = getIntegerValue(this, ("Voting_End_TimeStamp_" + toString(Porposal_ID))) |
---|
88 | | - | let pubkey = toBase58String(i.caller.bytes) |
---|
89 | | - | let readA4AStakingAmount = valueOrErrorMessage(getInteger(A4AStakingDApp, ("Deposit_Amount_Of_" + pubkey)), "Address not found in A4A Staking.") |
---|
90 | | - | let readQuoraumValue = getIntegerValue(this, ("Minimum_Quorum_" + toString(Porposal_ID))) |
---|
91 | | - | let Previoustotalvotes = match getInteger(this, ("Total_Votes_" + toString(Porposal_ID))) { |
---|
92 | | - | case a: Int => |
---|
93 | | - | a |
---|
94 | | - | case _ => |
---|
95 | | - | 0 |
---|
96 | | - | } |
---|
97 | | - | let totalvotes = (Previoustotalvotes + readA4AStakingAmount) |
---|
98 | | - | let FTVO = match getInteger(this, ((("Total_" + VoteAst) + "_") + toString(Porposal_ID))) { |
---|
99 | | - | case a: Int => |
---|
100 | | - | a |
---|
101 | | - | case _ => |
---|
102 | | - | 0 |
---|
103 | | - | } |
---|
104 | | - | let ATVO = (FTVO + readA4AStakingAmount) |
---|
105 | | - | let PreviousUserCountforVoting = match getInteger(this, ((pubkey + "_") + toString(Porposal_ID))) { |
---|
106 | | - | case a: Int => |
---|
107 | | - | a |
---|
108 | | - | case _ => |
---|
109 | | - | 0 |
---|
110 | | - | } |
---|
111 | | - | let LatestUserCountforVoting = (PreviousUserCountforVoting + 1) |
---|
112 | | - | if ((StartTS > lastBlock.timestamp)) |
---|
113 | | - | then throw((launch_error + toString(StartTS))) |
---|
114 | | - | else if ((lastBlock.timestamp > EndTS)) |
---|
115 | | - | then throw(voteErr) |
---|
116 | | - | else if ((readQuoraumValue > totalvotes)) |
---|
117 | | - | then [IntegerEntry(("Total_Votes_" + toString(Porposal_ID)), totalvotes), IntegerEntry(((("Total_" + VoteAst) + "_") + toString(Porposal_ID)), ATVO), IntegerEntry(((pubkey + "_") + toString(Porposal_ID)), LatestUserCountforVoting), StringEntry(("Quorum_Status_" + toString(Porposal_ID)), "Fail"), StringEntry("message", msg)] |
---|
118 | | - | else if ((totalvotes > readQuoraumValue)) |
---|
119 | | - | then [IntegerEntry(("Total_Votes_" + toString(Porposal_ID)), totalvotes), IntegerEntry(((("Total_" + VoteAst) + "_") + toString(Porposal_ID)), ATVO), IntegerEntry(((pubkey + "_") + toString(Porposal_ID)), LatestUserCountforVoting), StringEntry(("Quorum_Status_" + toString(Porposal_ID)), "Pass"), StringEntry("message", msg)] |
---|
120 | | - | else throw("Wrong Value Entered.") |
---|
121 | | - | } |
---|
122 | | - | |
---|
123 | | - | |
---|
124 | | - | @Verifier(tx) |
---|
125 | | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|