Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QSI_Groupe1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lydia Tarmelit
QSI_Groupe1
Commits
3e9bde6e
Commit
3e9bde6e
authored
1 year ago
by
Joe El hajj
Browse files
Options
Downloads
Patches
Plain Diff
4 endpoints
parent
31e735b1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
contracts/AssociationRegistry.jsligo
+28
-49
28 additions, 49 deletions
contracts/AssociationRegistry.jsligo
with
29 additions
and
50 deletions
README.md
+
1
−
1
View file @
3e9bde6e
# QSI_Groupe1
l'adresse du contrat: KT1QTwmF2eptKss2FWbT1rHP5wCERL16kihQ
## Getting started
...
...
This diff is collapsed.
Click to expand it.
contracts/AssociationRegistry.jsligo
+
28
−
49
View file @
3e9bde6e
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.01
tez;
const registrationFeeInitial=
10000000mu
tez;
// Register a new DAO
@entry
const registerAssociation = (association: association, storage: storage): return_ => {
//Addresse of MyAsso
const ownerAddress = ("tz1dV9UkbS6uMuKjQy5Vs7FSptKz8LR28oFq" as address)
const receiver : contract<unit> =
match (Tezos.get_contract_opt(
Option.unopt(association.admin)
) as option<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.01
tez,receiver);
const payoutOperation : operation =Tezos.transaction(unit,
10000000mu
tez,receiver);
const _operations : list <operation> = list([payoutOperation]);
// Check if association already exists
}
const existingAssociation =
Big_m
ap.mem(association.name, storage);
const existingAssociation =
M
ap.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_m
ap.add(association.name, newAssociation, storage);
const updatedStorage: storage =
M
ap.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_m
ap.find_opt(associationName, stor)){
return match(
M
ap.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 ;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment