diff --git a/README.md b/README.md
index f48ea3be7d279042fb1e51508a7ac129ed982efb..7fced9f4304871367c78bded2a381d0a78de485c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# QSI_Groupe1
-
+l'adresse du contrat: KT1QTwmF2eptKss2FWbT1rHP5wCERL16kihQ
## Getting started
diff --git a/contracts/AssociationRegistry.jsligo b/contracts/AssociationRegistry.jsligo
index 27b6ce8d84ce474a83b7aff204831fbac6ded042..1da82935ba8a14fd69f388a7bbb88b65bf1e7293 100644
--- a/contracts/AssociationRegistry.jsligo
+++ b/contracts/AssociationRegistry.jsligo
@@ -1,46 +1,37 @@
-type coordinate = {
- x: int;
- y: int;
- z: int;
-}
-
-type associationStatus =
- | ["Active"]
- | ["Inactive"]
- | ["Pending"];
-
type association = {
name: string;
description: string;
admin: option<address>;
};
-type storage = big_map<string, association>;
+type storage = map<string, association>;
type return_ = [list<operation>, storage];
-const registrationFeeInitial= 0.01tez;
+const registrationFeeInitial= 10000000mutez;
// Register a new DAO
@entry
const registerAssociation = (association: association, storage: storage): return_ => {
- const receiver : contract<unit> =
- match (Tezos.get_contract_opt(Option.unopt(association.admin)) as option<contract<unit>>) {
+ //Addresse of MyAsso
+ const ownerAddress = ("tz1dV9UkbS6uMuKjQy5Vs7FSptKz8LR28oFq" as address)
+const receiver : contract<unit> =
+ match (Tezos.get_contract_opt(ownerAddress) as option<contract<unit>>) {
when(Some(contract)): contract;
when(None()): (failwith ("Not a contract") as contract<unit>)
}
// Check if walletAmount is present and greater than or equal to registrationFeeInitial
- if (Tezos.get_amount()!= 0tez) {
- failwith("Insufficient funds to register association");
- }
+ // if ((Tezos.get_balance())> registrationFeeInitial) {
+ // failwith("Insufficient funds to register association");
+ // }
if(Some(Tezos.get_sender())== association.admin)
{
- const payoutOperation : operation =Tezos.transaction(unit,0.01tez,receiver);
+ const payoutOperation : operation =Tezos.transaction(unit,10000000mutez,receiver);
const _operations : list <operation> = list([payoutOperation]);
// Check if association already exists
}
- const existingAssociation = Big_map.mem(association.name, storage);
+ const existingAssociation = Map.mem(association.name, storage);
if (existingAssociation) {
failwith("Association already registered");
}
@@ -52,56 +43,44 @@ const registerAssociation = (association: association, storage: storage): return
};
// Add new association to storage
- const updatedStorage: storage = Big_map.add(association.name, newAssociation, storage);
+ const updatedStorage: storage = Map.add(association.name, newAssociation, storage);
return [list([]), updatedStorage];
}
//Change Admin
-
@entry
-const changeAdmin = (associationName: string, stor: storage): return_ => {
- const associationOpt = Big_map.find_opt(associationName, stor);
- if (Option.is_none(associationOpt)) {
- failwith("Unknown association cannot change admin");
- }
- const association = Option.unopt_with_error(associationOpt, "Failed to get association");
-
- const senderAddress = Tezos.get_sender();
- if (!Option.is_some(association.admin) || senderAddress != Option.unopt(association.admin)) {
+const changeAdmin: (params: {associationName: string, newAdmin: address}, storage: storage) => return_ = (params, storage) => {
+ const {associationName, newAdmin} = params;
+ const existingAssociation = Map.find_opt(associationName, storage);
+ const association = Option.unopt_with_error(existingAssociation, "Unknown assocation");
+ // Check if the sender is the current admin
+ if (Some(Tezos.get_sender()) != association.admin) {
failwith("Only the current admin can change the admin");
}
- const updatedAssociation = {
+ // Update the association with the new admin address
+ const updatedAssociation: association = {
...association,
- admin: Some(senderAddress)
+ admin: Some(newAdmin),
};
- const updatedStorage = Big_map.update(associationName, Some(updatedAssociation), stor);
+ // Update the storage with the modified association
+ const updatedStorage = Map.update(associationName, Some(updatedAssociation), storage);
return [list([]), updatedStorage];
-}
+};
//details d'une associations
@view
const listDetailsAssociations = (associationName:string, stor: storage): association => {
- return match(Big_map.find_opt(associationName, stor)){
+ return match(Map.find_opt(associationName, stor)){
when(Some(value)): value;
when(None): failwith("No value.")
};
}
-// Function to list details of all associations
-// @view
-// const listAllAssociations = (stor: storage): list<association> => {
-// const associations: list<association> = list([]);
-// const keys = Big_map.of_lnist(stor);
-// for (const name of keys) {
-// const association = Big_map.find_opt(name, stor);
-// if (Option.is_some(association)) {
-// associations.push(Option.unopt(association));
-// }
-// }
-// return associations;
-// }
\ No newline at end of file
+@view
+const listAllAssociations = (_unused : unit,stor: storage): storage=> stor ;
+