diff --git a/contracts/AssociationRegistry.jsligo b/contracts/AssociationRegistry.jsligo
index 3977f5a3921bd0df82c90c41aeba0746dca31d14..790aa9cd7a6c727e70e1b4e03156094f4622a300 100644
--- a/contracts/AssociationRegistry.jsligo
+++ b/contracts/AssociationRegistry.jsligo
@@ -1,73 +1,79 @@
-
-type coordinate = {
- x: int;
- y: int;
- z: int;
-};
-
-type associationStatus =
- | ["Active"]
- | ["Inactive"]
- | ["Pending"];
-
-type association = {
- name: string;
- coordinate: coordinate;
- status: associationStatus;
- admin: option<address>;
- registrationFee: tez;
-};
-
-type storage = big_map<string, association>;
-
-type return_ = [list<operation>, storage];
-
-
-const registrationFeeInitial: tez = 10 as tez;
-
-
-@entry
-function registerAssociation(newAssociation: association, storage: storage): return_ {
- const existingAssociation = Big_map.find_opt(newAssociation.name, storage);
- if (Option.is_some(existingAssociation)) {
- failwith("Association already registered");
- }
- const updatedStorage: storage = Big_map.add(newAssociation.name, {
- ...newAssociation,
- registrationFee: registrationFeeInitial
- }, storage);
-
- const noOperations: list<operation> = [];
- const result: return_ = [noOperations, updatedStorage];
- return result;
-}
-
-
-@entry
-function changeAdmin(associationName: string, newAdmin: address, storage: storage): return_ {
- const associationOpt = Big_map.find_opt(associationName, storage);
- if (Option.is_none(associationOpt)) {
- failwith("Unknown association cannot change admin");
- }
- let association = Option.get(associationOpt);
-
- if (Option.is_none(association.admin) || Tezos.sender != Option.get(association.admin)) {
- failwith("Only the current admin can change the admin");
- }
-
- const updatedAssociation = {
- ...association,
- admin: Some(newAdmin)
- };
- const updatedStorage: storage = Big_map.update(associationName, Some(updatedAssociation), storage);
-
- const noOperations: list<operation> = [];
- const result: return_ = [noOperations, updatedStorage];
- return result;
-}
-
-
-@view
-function getAssociationDetails(associationName: string, storage: storage): option<association> {
- return Big_map.find_opt(associationName, storage);
-}
+
+type coordinate = {
+ x: int;
+ y: int;
+ z: int;
+}
+
+type associationStatus =
+ | ["Active"]
+ | ["Inactive"]
+ | ["Pending"];
+
+type association = {
+ name: string;
+ coordinate: coordinate;
+ status: associationStatus;
+ admin: option<address>;
+ registrationFee: tez;
+};
+
+type storage = big_map<string, association>;
+
+type return_ = [list<operation>, storage];
+
+
+const registrationFeeInitial: tez = 10 as tez;
+
+//Register a new DAO
+@entry
+function registerAssociation(newAssociation: association, storage: storage): return_ {
+ const existingAssociation = Big_map.find_opt(newAssociation.name, storage);
+ if (Option.is_some(existingAssociation)) {
+ failwith("Association already registered");
+ }
+ const updatedStorage: storage = Big_map.add(newAssociation.name, {
+ ...newAssociation,
+ registrationFee: registrationFeeInitial
+ }, storage);
+
+// Within the registerAssociation function
+const noOperations : list<operation> = list([]);
+
+
+
+ const result: return_ = [noOperations, updatedStorage];
+ return result;
+}
+
+//Change Admin
+@entry
+function changeAdmin(associationName, newAdmin, storage) {
+ const associationOpt = Big_map.find_opt(associationName, storage);
+ if (Option.is_none(associationOpt)) {
+ failwith("Unknown association cannot change admin");
+ }
+
+ const association = Option.unopt(associationOpt, () => failwith("Failed to get association"));
+ //todo
+ if (Some(Tezos.get_sender()) != association.admin) {
+ failwith("Only the current admin can change the admin");
+ }
+
+ const updatedAssociation = {
+ ...association,
+ admin: Some(newAdmin)
+ };
+
+ const updatedStorage = Big_map.update(associationName, Some(updatedAssociation), storage);
+
+ const noOperations: list<operation> = [];
+ const result: return_ = [noOperations, updatedStorage];
+ return result;
+}
+
+//List associations
+@view
+function getAssociationDetails(associationName: string, storage: storage): option<association> {
+ return Big_map.find_opt(associationName, storage);
+}