diff --git a/esy.lock/.gitattributes b/esy.lock/.gitattributes deleted file mode 100644 index e0b4e26..0000000 --- a/esy.lock/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ - -# Set eol to LF so files aren't converted to CRLF-eol on Windows. -* text eol=lf linguist-generated diff --git a/esy.lock/.gitignore b/esy.lock/.gitignore deleted file mode 100644 index a221be2..0000000 --- a/esy.lock/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# Reset any possible .gitignore, we want all esy.lock to be un-ignored. -!* diff --git a/esy.lock/index.json b/esy.lock/index.json deleted file mode 100644 index d5a784f..0000000 --- a/esy.lock/index.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "checksum": "e92ce686850cf2560180a590d07494d3", - "root": "@ligo/dao@link-dev:./package.json", - "node": { - "@ligo/fa@1.0.6@d41d8cd9": { - "id": "@ligo/fa@1.0.6@d41d8cd9", - "name": "@ligo/fa", - "version": "1.0.6", - "source": { - "type": "install", - "source": [ - "archive:https://packages.ligolang.org/-/api/@ligo/fa/-/@ligo/fa-1.0.6.tgz#sha1:94927de94317e20b350e51ecfa90a647c322e665" - ] - }, - "overrides": [], - "dependencies": [], - "devDependencies": [] - }, - "@ligo/dao@link-dev:./package.json": { - "id": "@ligo/dao@link-dev:./package.json", - "name": "@ligo/dao", - "version": "link-dev:./package.json", - "source": { - "type": "link-dev", - "path": ".", - "manifest": "package.json" - }, - "overrides": [], - "dependencies": [ "@ligo/fa@1.0.6@d41d8cd9" ], - "devDependencies": [] - } - } -} \ No newline at end of file diff --git a/package.json b/ligo.json similarity index 100% rename from package.json rename to ligo.json diff --git a/src/main.mligo b/src/main.mligo index fcbdf13..7340993 100644 --- a/src/main.mligo +++ b/src/main.mligo @@ -9,20 +9,11 @@ #import "./vault.mligo" "Vault" #import "./timelock.mligo" "Timelock" -type parameter = - [@layout:comb] - | Propose of Proposal.make_params - | Cancel of nat option - | Lock of Vault.amount_ - | Release of Vault.amount_ - | Execute of Outcome.execute_params - | Vote of Vote.choice - | End_vote - type storage = Storage.t type result = operation list * storage -let execute (outcome_key, packed, s: nat * bytes * storage) : result = +[@entry] let execute (p : Outcome.execute_params) (s : storage) : result = + let { outcome_key; packed } = p in let proposal = (match Big_map.find_opt outcome_key s.outcomes with None -> failwith Errors.outcome_not_found | Some(o) -> Outcome.get_executable_proposal(o)) in @@ -42,7 +33,7 @@ let execute (outcome_key, packed, s: nat * bytes * storage) : result = Storage.update_config(f,s) ) -let propose (p, s : Proposal.make_params * storage) : result = +[@entry] let propose (p : Proposal.make_params) (s : storage) : result = match s.proposal with Some(_) -> failwith Errors.proposal_already_exists | None -> [ @@ -55,7 +46,7 @@ let propose (p, s : Proposal.make_params * storage) : result = Proposal.make(p, s.config.start_delay, s.config.voting_period), s) -let cancel (outcome_key_opt, s : nat option * storage) : result = +[@entry] let cancel (outcome_key_opt : nat option) (s : storage) : result = [Token.transfer( s.governance_token, Tezos.get_self_address(), @@ -81,7 +72,7 @@ let cancel (outcome_key_opt, s : nat option * storage) : result = let () = Timelock._check_locked(p.timelock) in Storage.update_outcome(outcome_key, (p, Canceled), s))) -let lock (amount_, s : nat * storage) : result = +[@entry] let lock (amount_ : nat) (s : storage) : result = let () = Proposal._check_no_vote_ongoing(s.proposal) in let current_amount = Vault.get_for_user(s.vault, Tezos.get_sender()) in @@ -94,7 +85,7 @@ let lock (amount_, s : nat * storage) : result = Tezos.get_sender(), current_amount + amount_), s) -let release (amount_, s : nat * storage) : result = +[@entry] let release (amount_ : nat) (s : storage) : result = let () = Proposal._check_no_vote_ongoing(s.proposal) in let current_amount = Vault.get_for_user_exn(s.vault, Tezos.get_sender()) in let _check_balance = assert_with_error @@ -107,14 +98,14 @@ let release (amount_, s : nat * storage) : result = Tezos.get_sender(), abs(current_amount - amount_)), s) -let vote (choice, s : bool * storage) : storage = - match s.proposal with +[@entry] let vote (choice : bool) (s : storage) : result = + Constants.no_operation, (match s.proposal with None -> failwith Errors.no_proposal | Some(p) -> let () = Proposal._check_is_voting_period(p) in let amount_ = Vault.get_for_user_exn(s.vault, Tezos.get_sender()) in - Storage.update_votes(p, (choice, amount_), s) + Storage.update_votes(p, (choice, amount_), s)) -let end_vote (s : storage) : result = +[@entry] let end_vote (_ : unit) (s : storage) : result = match s.proposal with None -> failwith Errors.no_proposal | Some(p) -> let () = Proposal._check_voting_period_ended(p) in @@ -139,16 +130,3 @@ let end_vote (s : storage) : result = transfer_to_addr, s.config.deposit_amount)] ), Storage.add_outcome(outcome, s) - -let main (action : parameter) (store : storage) : result = - let _check_amount_is_zero = assert_with_error - (Tezos.get_amount() = 0tez) - Errors.not_zero_amount - in match action with - Propose p -> propose(p, store) - | Cancel n_opt -> cancel(n_opt, store) - | Lock n -> lock(n, store) - | Release n -> release(n, store) - | Execute p -> execute(p.outcome_key, p.packed, store) - | Vote v -> Constants.no_operation, vote(v, store) - | End_vote -> end_vote(store) diff --git a/test/bootstrap/single_asset.mligo b/test/bootstrap/single_asset.mligo index 5fa026c..fa09cf5 100644 --- a/test/bootstrap/single_asset.mligo +++ b/test/bootstrap/single_asset.mligo @@ -2,5 +2,5 @@ (* Extension of FA2 to be used as governance token of the DAO *) -[@view] let total_supply (_, _s : unit * storage) : nat = +[@view] let total_supply (_ : unit) (_s : storage) : nat = 30n diff --git a/test/helpers/dao.mligo b/test/helpers/dao.mligo index ddb4649..f8707c0 100644 --- a/test/helpers/dao.mligo +++ b/test/helpers/dao.mligo @@ -2,8 +2,8 @@ #import "./assert.mligo" "Assert" (* Some types for readability *) -type taddr = (DAO.parameter, DAO.storage) typed_address -type contr = DAO.parameter contract +type taddr = (DAO parameter_of, DAO.storage) typed_address +type contr = DAO parameter_of contract type originated = { addr: address; taddr: taddr; @@ -51,13 +51,13 @@ let base_storage : DAO.storage = { (* Originate a DAO contract with given init_storage storage *) let originate (init_storage: DAO.storage) = - let (taddr, _, _) = Test.originate DAO.main init_storage 0tez in + let (taddr, _, _) = Test.originate_module (contract_of DAO) init_storage 0tez in let contr = Test.to_contract taddr in let addr = Tezos.address contr in { addr = addr; taddr = taddr; contr = contr } (* Call entry point of DAO contr contract *) -let call (p, contr : DAO.parameter * contr) = +let call (p, contr : DAO parameter_of * contr) = Test.transfer_to_contract contr p 0mutez (* Entry points call helpers *) diff --git a/test/helpers/token.mligo b/test/helpers/token.mligo index 8f74ca0..660e448 100644 --- a/test/helpers/token.mligo +++ b/test/helpers/token.mligo @@ -3,8 +3,8 @@ #import "./assert.mligo" "Assert" (* Some types for readability *) -type taddr = (SingleAsset.parameter, SingleAsset.storage) typed_address -type contr = SingleAsset.parameter contract +type taddr = (SingleAsset parameter_of, SingleAsset.storage) typed_address +type contr = SingleAsset parameter_of contract type originated = { addr: address; taddr: taddr; @@ -19,7 +19,7 @@ let originate (tok_amount : nat) = tok_amount, tok_amount, tok_amount ) in let v_mich = Test.run (fun (x:SingleAsset.Storage.t) -> x) init_storage in - let (addr, _, _) = Test.originate_from_file f "main" (["total_supply"]: string list) v_mich 0tez in + let (addr, _, _) = Test.originate_from_file f v_mich 0tez in let taddr : taddr = Test.cast_address addr in let contr = Test.to_contract taddr in { @@ -48,7 +48,7 @@ let transfer (contr, from_, to_, amount_ : contr * address * address * nat) = Test.transfer_to_contract_exn contr (Transfer transfer_requests) 0tez (* Batch add [operators] to [contr] contract *) -let add_operators (operators, contr : SingleAsset.operator list * SingleAsset.parameter contract) = +let add_operators (operators, contr : SingleAsset.operator list * SingleAsset parameter_of contract) = let f (ys,x : (SingleAsset.unit_update list * SingleAsset.operator)) : SingleAsset.unit_update list = (Add_operator(x) : SingleAsset.unit_update) :: ys in let add_operator = List.fold_left f ([] : SingleAsset.unit_update list) operators in let r = Test.transfer_to_contract contr (Update_operators(add_operator)) 0mutez in