Skip to content
Snippets Groups Projects
Commit dcccea79 authored by Joe El hajj's avatar Joe El hajj
Browse files

4 endpoints

parent 3e9bde6e
Branches
No related tags found
No related merge requests found
# QSI_Groupe1 # QSI_Groupe1
l'adresse du contrat: KT1QTwmF2eptKss2FWbT1rHP5wCERL16kihQ l'adresse du contrat: KT1KDh3oWApHysHWdcDuFuNhk1WoVvJTtsDF
## Getting started ## Getting started
......
...@@ -8,29 +8,30 @@ type storage = map<string, association>; ...@@ -8,29 +8,30 @@ type storage = map<string, association>;
type return_ = [list<operation>, storage]; type return_ = [list<operation>, storage];
const myAssoAdmin = ("tz1aek2YDiM5xxqZwus1eyR3siiSNjmiJfFM" as address) ;
const registrationFeeInitial= 10000000mutez; const registrationFeeInitial= 10 as mutez;
// Register a new DAO // Register a new DAO
@entry @entry
const registerAssociation = (association: association, storage: storage): return_ => { const registerAssociation = (association: association, storage: storage): return_ => {
//Addresse of MyAsso let operations : list<operation> = list([]) ;
const ownerAddress = ("tz1dV9UkbS6uMuKjQy5Vs7FSptKz8LR28oFq" as address)
const receiver : contract<unit> = const receiver : contract<unit> =
match (Tezos.get_contract_opt(ownerAddress) as option<contract<unit>>) { match ((Tezos.get_contract_opt(myAssoAdmin))) {
when(Some(contract)): contract; when(Some(contract)): contract;
when(None()): (failwith ("Not a contract") as contract<unit>) when(None()): (failwith ("Not a contract") as contract<unit>)
} }
// Check if walletAmount is present and greater than or equal to registrationFeeInitial // Check if walletAmount is present and greater than or equal to registrationFeeInitial
// if ((Tezos.get_balance())> registrationFeeInitial) { if ((Tezos.get_amount())!= registrationFeeInitial) {
// failwith("Insufficient funds to register association"); failwith("The amount should be 10tez exactly");
// } }
if(Some(Tezos.get_sender())== association.admin) if(Some(Tezos.get_sender())== association.admin)
{ {
const payoutOperation : operation =Tezos.transaction(unit,10000000mutez,receiver); const payoutOperation : operation =Tezos.transaction(unit,registrationFeeInitial,receiver);
const _operations : list <operation> = list([payoutOperation]); operations = list([payoutOperation]);
// Check if association already exists // Check if association already exists
} }
const existingAssociation = Map.mem(association.name, storage); const existingAssociation = Map.mem(association.name, storage);
if (existingAssociation) { if (existingAssociation) {
failwith("Association already registered"); failwith("Association already registered");
...@@ -45,7 +46,7 @@ const receiver : contract<unit> = ...@@ -45,7 +46,7 @@ const receiver : contract<unit> =
// Add new association to storage // Add new association to storage
const updatedStorage: storage = Map.add(association.name, newAssociation, storage); const updatedStorage: storage = Map.add(association.name, newAssociation, storage);
return [list([]), updatedStorage]; return [operations, updatedStorage];
} }
...@@ -83,4 +84,3 @@ const listDetailsAssociations = (associationName:string, stor: storage): associa ...@@ -83,4 +84,3 @@ const listDetailsAssociations = (associationName:string, stor: storage): associa
@view @view
const listAllAssociations = (_unused : unit,stor: storage): storage=> stor ; const listAllAssociations = (_unused : unit,stor: storage): storage=> stor ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment