Skip to content
Snippets Groups Projects
Commit 2d1cf893 authored by Lydia Tarmelit's avatar Lydia Tarmelit
Browse files

deploy and set story 1 , 2 , 3 ,4

parent 34817b3b
No related branches found
No related tags found
No related merge requests found
......@@ -15,10 +15,7 @@ type association = {
admin: option<address>;
};
type storage = {
associations: big_map<string, association>,
associationNames: list<string>
};
type storage = big_map<string, association>;
type return_ = [list<operation>, storage];
......@@ -28,29 +25,34 @@ const registrationFeeInitial= 10 as tez;
// Register a new DAO
@entry
const registerAssociation = (association: association, storage: storage): return_ => {
// Check if walletAmount is present and greater than or equal to registrationFeeInitial
if (Tezos.get_amount () < registrationFeeInitial) {
failwith("Insufficient funds to register association");
}
const existingAssociation = Big_map.mem(association.name, storage.associations);
// Check if association already exists
const existingAssociation = Big_map.mem(association.name, storage);
if (existingAssociation) {
failwith("Association already registered");
}
const updatedAssociations: big_map<string, association> = Big_map.add(association.name, association, storage.associations);
const updatedAssociationNames: list<string> = List.cons(association.name, storage.associationNames);
const updatedStorage: storage = {
associations: updatedAssociations,
associationNames: updatedAssociationNames
// Deduct registration fee from wallet amount and create new association
const newAssociation: association = {
...association,
};
// Add new association to storage
const updatedStorage: storage = Big_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.associations);
const associationOpt = Big_map.find_opt(associationName, stor);
if (Option.is_none(associationOpt)) {
failwith("Unknown association cannot change admin");
}
......@@ -66,12 +68,7 @@ const changeAdmin = (associationName: string, stor: storage): return_ => {
admin: Some(senderAddress)
};
const updatedAssociations = Big_map.update(associationName, Some(updatedAssociation), stor.associations);
const updatedStorage: storage = {
associations: updatedAssociations,
associationNames: stor.associationNames // This remains unchanged
};
const updatedStorage = Big_map.update(associationName, Some(updatedAssociation), stor);
return [list([]), updatedStorage];
}
......@@ -79,27 +76,22 @@ const changeAdmin = (associationName: string, stor: storage): return_ => {
//details d'une associations
@view
const listDetailsAssociations = (associationName:string, stor: storage): association => {
return match(Big_map.find_opt(associationName, stor.associations)){
return match(Big_map.find_opt(associationName, stor)){
when(Some(value)): value;
when(None): failwith("No value.")
};
}
//todo Function to list details of all associations
@view
const listAllAssociations = (_:string, stor: storage): list<association> => {
let associationsList: list<association> = list([]);
// Iterate over each association name in the storage's list
for (const associationName of stor.associationNames) {
// Attempt to find the association details in the big_map using the name
const associationOpt = Big_map.find_opt(associationName, stor.associations);
// If the association is found (not None), add it to the associationsList
if (Option.is_some(associationOpt)) {
const association = Option.unopt(associationOpt);
associationsList = List.cons(association, associationsList);
}
}
return associationsList;
}
// Function to list details of all associations
// @view
// const listAllAssociations = (stor: storage): list<association> => {
// const associations: list<association> = list([]);
// const keys = Big_map.of_list(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
# Required: Your private key
PK=......
PK=
# Required: see see https://tezostaquito.io/docs/rpc_nodes/
RPC_URL=https://ghostnet.tezos.marigold.dev/
#Contract address:
- KT1PCg4GbtF5LQQhHmY4t1qNYVspnitKGHgm
\ No newline at end of file
# KT1PCg4GbtF5LQQhHmY4t1qNYVspnitKGHgm
# new adresse : KT1NMZvpAEQmezU8kHKzgi9PjysoH4VTcB3P
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment