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