|
|
|
@ -1,11 +1,12 @@
|
|
|
|
|
import "./messages"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Proposal { |
|
|
|
|
type: Int; // 0 - Blacklist, 1 - Full liquidation, 2 - Change percents |
|
|
|
|
blacklistAddress: Address?; |
|
|
|
|
distribution: Distribution?; |
|
|
|
|
distribution_addresses: map[Int]Address; |
|
|
|
|
distribution_addresses_length: Int? = null; |
|
|
|
|
distribution_percents: map[Int]Int; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct Vote { |
|
|
|
@ -81,7 +82,10 @@ contract Foundation {
|
|
|
|
|
// todo |
|
|
|
|
} |
|
|
|
|
if (prop.type == 2) { |
|
|
|
|
self.admins = prop.distribution!!; |
|
|
|
|
self.admins = Distribution{ |
|
|
|
|
addresses: AddressList{ addresses: prop.distribution_addresses, length: prop.distribution_addresses_length!! }, |
|
|
|
|
percents: prop.distribution_percents |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -109,7 +113,9 @@ contract Foundation {
|
|
|
|
|
let proposal: Proposal = Proposal { |
|
|
|
|
type: 0, |
|
|
|
|
blacklistAddress: msg.wallet, |
|
|
|
|
distribution: null |
|
|
|
|
distribution_addresses: emptyMap(), |
|
|
|
|
distribution_addresses_length: null, |
|
|
|
|
distribution_percents: emptyMap() |
|
|
|
|
}; |
|
|
|
|
let vote: Vote = Vote { |
|
|
|
|
id: self.n_votes, |
|
|
|
@ -128,34 +134,36 @@ contract Foundation {
|
|
|
|
|
self.n_votes = self.n_votes + 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// receive(msg: InitiateDistributionVote) { |
|
|
|
|
// let ctx: Context = context(); |
|
|
|
|
// require(ctx.sender == self.admins.addresses.addresses.get(msg.adminIndex), "Only an admin can initiate a vote"); |
|
|
|
|
// require(ctx.value >= ton("1.0"), "Voting requires at least 1 ton for the fees"); |
|
|
|
|
// require(msg.quorum_percent > 20 && msg.quorum_percent <= 100, "Invalid quorum percent"); |
|
|
|
|
// require(msg.vote_time > 0 && msg.vote_time < 3 * 24 * 3600, "Invalid vote time"); |
|
|
|
|
// let proposal: Proposal = Proposal { |
|
|
|
|
// type: 2, |
|
|
|
|
// blacklistAddress: null, |
|
|
|
|
// distribution: msg.distribution |
|
|
|
|
// }; |
|
|
|
|
|
|
|
|
|
// let vote: Vote = Vote { |
|
|
|
|
// id: self.n_votes, |
|
|
|
|
// vote_end: now() + msg.vote_time, |
|
|
|
|
// proposal: proposal, |
|
|
|
|
// quorum_percent: msg.quorum_percent, |
|
|
|
|
// votes: emptyMap(), |
|
|
|
|
// result: null |
|
|
|
|
// }; |
|
|
|
|
// let i: Int = 0; |
|
|
|
|
// while (i < self.admins.addresses.length) { |
|
|
|
|
// vote.votes.set(i, -1); |
|
|
|
|
// i = i + 1; |
|
|
|
|
// } |
|
|
|
|
// self.votes.set(self.n_votes, vote); |
|
|
|
|
// self.n_votes = self.n_votes + 1; |
|
|
|
|
// } |
|
|
|
|
receive(msg: InitiateDistributionVote) { |
|
|
|
|
let ctx: Context = context(); |
|
|
|
|
require(ctx.sender == self.admins.addresses.addresses.get(msg.adminIndex), "Only an admin can initiate a vote"); |
|
|
|
|
require(ctx.value >= ton("1.0"), "Voting requires at least 1 ton for the fees"); |
|
|
|
|
require(msg.quorum_percent > 20 && msg.quorum_percent <= 100, "Invalid quorum percent"); |
|
|
|
|
require(msg.vote_time > 0 && msg.vote_time < 3 * 24 * 3600, "Invalid vote time"); |
|
|
|
|
let proposal: Proposal = Proposal { |
|
|
|
|
type: 2, |
|
|
|
|
blacklistAddress: null, |
|
|
|
|
distribution_addresses: msg.distribution.addresses.addresses, |
|
|
|
|
distribution_addresses_length: msg.distribution.addresses.length, |
|
|
|
|
distribution_percents: msg.distribution.percents |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let vote: Vote = Vote { |
|
|
|
|
id: self.n_votes, |
|
|
|
|
vote_end: now() + msg.vote_time, |
|
|
|
|
quorum_percent: msg.quorum_percent, |
|
|
|
|
votes: emptyMap(), |
|
|
|
|
result: null |
|
|
|
|
}; |
|
|
|
|
let i: Int = 0; |
|
|
|
|
while (i < self.admins.addresses.length) { |
|
|
|
|
vote.votes.set(i, -1); |
|
|
|
|
i = i + 1; |
|
|
|
|
} |
|
|
|
|
self.votes.set(self.n_votes, vote); |
|
|
|
|
self.proposals.set(self.n_votes, proposal); |
|
|
|
|
self.n_votes = self.n_votes + 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
receive(msg: InitiateLiquidationVote) { |
|
|
|
|
let ctx: Context = context(); |
|
|
|
@ -178,7 +186,9 @@ contract Foundation {
|
|
|
|
|
let proposal: Proposal = Proposal { |
|
|
|
|
type: 1, |
|
|
|
|
blacklistAddress: null, |
|
|
|
|
distribution: null |
|
|
|
|
distribution_addresses: emptyMap(), |
|
|
|
|
distribution_addresses_length: null, |
|
|
|
|
distribution_percents: emptyMap() |
|
|
|
|
}; |
|
|
|
|
self.votes.set(self.n_votes, vote); |
|
|
|
|
self.proposals.set(self.n_votes, proposal); |
|
|
|
|