Skip to content

Commit 2da79db

Browse files
committed
WIP on master
1 parent b0ab8d5 commit 2da79db

File tree

16 files changed

+458
-164
lines changed

16 files changed

+458
-164
lines changed

Cargo.lock

+5-114
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ exclude = [".github"]
3939
[lib]
4040
name = "sonare"
4141

42+
[[example]]
43+
name = "dao"
44+
4245
[dependencies]
4346
amplify.workspace = true
4447
baid64 = "0.4.0"
@@ -74,4 +77,5 @@ wasm-bindgen-test = "0.3"
7477
features = ["all"]
7578

7679
[patch.crates-io]
80+
commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.12" }
7781
ultrasonic = { git = "https://github.com/AluVM/ultrasonic" }

example/dao.con examples/dao.con

+18-5
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,31 @@ data Vote: contra | pro
2525
data Voting: title String,
2626
text Text
2727

28+
data CastVote: voteId VoteId, partyId PartyId, vote Vote
29+
2830
lock Signer: [U8 ^ 32]
2931
verify: preimage [U8 ^ 32]
30-
hash preimage =?= $ !! invalidPreimage
32+
sha256 preimage =?= $ !! invalidPreimage
3133

3234
@issuer(indsc.org)
3335
contract DAO
34-
var parties: { PartyId -> Party }
36+
var parties: { @verifiable PartyId -> @associated Party }
37+
var votings: { @verifiable VoteId -> @associated Voting }
38+
var votes: { @verifiable CastVote }
39+
40+
var signers: { Signer -> PartyId }
3541

36-
var votings: { VoteId -> Voting }
37-
var votes: { VoteId -> { PartyId -> Vote } }
42+
calc votingCount: () -> U64
43+
count $.votings
44+
45+
calc totalVotes: vote_id VoteId -> U64
46+
count($.votes |> (key, voting) -> key =?= vote_id)
3847

39-
var signers: { Signer -> PartyId }
48+
calc proVotes: vote_id VoteId -> U64
49+
count($.votes |> (key, voting) -> key =?= vote_id \/ voting =?= pro)
50+
51+
calc conterVotes: vote_id VoteId -> U64
52+
count($.votes |> (key, voting) -> key =?= vote_id \/ voting =?= counter)
4053

4154
op setup: () -> parties, signers
4255

0 commit comments

Comments
 (0)