Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the ballot struct #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions 3.restricted-mint-multisig/imports/multisig.leo
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ program multisig.aleo {
mapping required_signatures: bool => u64;
mapping proposals: Proposal => u64;
mapping signers: address => bool;

mapping votes: Ballot => bool;
struct Ballot{
proposal: Proposal,
signer: address
}
struct Proposal {
program_address: address,
function_id: field,
args_hash: field,
}

record ticket {
owner: address,
program_address: address,
Expand Down Expand Up @@ -40,9 +43,16 @@ program multisig.aleo {
}

finalize sign(caller: address, proposal: Proposal) {

assert(Mapping::get(signers, caller));
let ballot: Ballot = Ballot {
proposal: proposal,
signer: caller
};
assert_eq(Mapping::get(votes, ballot),false);
let signatures: u64 = Mapping::get_or_use(proposals, proposal, 0u64);
Mapping::set(proposals, proposal, signatures + 1u64);
Mapping::set(votes,ballot,true);
}

transition add_signer(ticket_: ticket, new_signer: address) {
Expand Down