Skip to content

Commit

Permalink
Merge pull request #4 from crisdut/fix/example
Browse files Browse the repository at this point in the history
Fix example
  • Loading branch information
dr-orlovsky authored Jan 13, 2025
2 parents 5e32310 + 75b681e commit e57f736
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/dao/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ extern crate amplify;
#[macro_use]
extern crate strict_types;

use std::fs;
use std::path::Path;

use aluvm::{CoreConfig, LibSite};
use amplify::num::u256;
use commit_verify::{Digest, Sha256};
Expand Down Expand Up @@ -98,7 +101,7 @@ fn api() -> Api {
vname!("parties") => EmbeddedReaders::MapV2U(vname!("_parties")),
vname!("votings") => EmbeddedReaders::MapV2U(vname!("_votings")),
vname!("votes") => EmbeddedReaders::SetV(vname!("_votes")),
vname!("votingCount") => EmbeddedReaders::Count(vname!("votings")),
vname!("votingCount") => EmbeddedReaders::Count(vname!("_votings")),
},
verifiers: tiny_bmap! {
vname!("setup") => 0,
Expand Down Expand Up @@ -149,6 +152,11 @@ fn main() {
.finish::<0>("WonderlandDAO", 1732529307);
let opid = articles.contract.genesis_opid();

let contract_path = Path::new("examples/dao/data/WonderlandDAO.contract");
if contract_path.exists() {
fs::remove_dir_all(contract_path).expect("unable to remove contract file");
}

let mut stock = Stock::new(articles, "examples/dao/data");

// Proposing vote
Expand Down Expand Up @@ -206,6 +214,11 @@ fn main() {
}

// Now anybody accessing this file can figure out who is on duty today, by the decision of DAO.
let deeds_path = Path::new("examples/dao/data/voting.deeds");
if deeds_path.exists() {
fs::remove_file(deeds_path).expect("unable to remove contract file");
}

stock
.export_to_file([alice_auth2, bob_auth2, carol_auth2], "examples/dao/data/voting.deeds")
.expect("unable to save deeds to a file");
Expand Down

0 comments on commit e57f736

Please sign in to comment.