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
e5efa1a1
Commit
e5efa1a1
authored
1 year ago
by
Joe El hajj
Browse files
Options
Downloads
Patches
Plain Diff
Update AssociationRegistry.jsligo modify change admin
parent
0065edd1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
contracts/AssociationRegistry.jsligo
+27
-19
27 additions, 19 deletions
contracts/AssociationRegistry.jsligo
with
27 additions
and
19 deletions
contracts/AssociationRegistry.jsligo
+
27
−
19
View file @
e5efa1a1
type coordinate = {
type coordinate = {
x: int;
x: int;
y: int;
y: int;
...
@@ -28,8 +27,8 @@ const registrationFeeInitial: tez = 10 as tez;
...
@@ -28,8 +27,8 @@ const registrationFeeInitial: tez = 10 as tez;
//Register a new DAO
//Register a new DAO
@entry
@entry
function registerAssociation(newAssociation: association, storage: storage): return_ {
function registerAssociation(newAssociation: association, storage: storage): return_ {
const existingAssociation = Big_map.
find_opt
(newAssociation.name, storage);
const existingAssociation = Big_map.
mem
(newAssociation.name, storage);
if
(Option.is_some
(existingAssociation)
)
{
if (existingAssociation) {
failwith("Association already registered");
failwith("Association already registered");
}
}
const updatedStorage: storage = Big_map.add(newAssociation.name, {
const updatedStorage: storage = Big_map.add(newAssociation.name, {
...
@@ -39,38 +38,47 @@ function registerAssociation(newAssociation: association, storage: storage): ret
...
@@ -39,38 +38,47 @@ function registerAssociation(newAssociation: association, storage: storage): ret
// Within the registerAssociation function
// Within the registerAssociation function
const noOperations : list<operation> = list([]);
const noOperations : list<operation> = list([]);
const result: return_ = [noOperations, updatedStorage];
const result: return_ = [noOperations, updatedStorage];
return result;
return result;
}
}
//Change Admin
//Change Admin
@entry
@entry
function changeAdmin(associationName, newAdmin
,
storage) {
function changeAdmin(associationName
:string
, newAdmin
: address, stor:
storage) {
const associationOpt = Big_map.find_opt(associationName, stor
age
);
const associationOpt = Big_map.find_opt(associationName, stor);
if (Option.is_none(associationOpt)) {
if (Option.is_none(associationOpt)) {
failwith("Unknown association cannot change admin");
failwith("Unknown association cannot change admin");}
}
const association = Option.unopt_with_error(associationOpt,"Failed to get association");
const association = Option.unopt(associationOpt, () => failwith("Failed to get association"));
//todo
//todo
if (Some(Tezos.get_sender()) != association.admin) {
const senderAddress = Tezos.get_sender();
if (!Option.is_some(association.admin) || senderAddress != Option.unopt(association.admin)) {
failwith("Only the current admin can change the admin");
failwith("Only the current admin can change the admin");
}
}
const updatedAssociation = {
const updatedAssociation = {
...association,
...association,
admin: Some(newAdmin)
admin: Some(newAdmin)
}
const updatedStorage = Big_map.update(associationName, Some(updatedAssociation), stor);
return [list([],updatedStorage)]
};
};
/*
@entry
const destroy = (planetName: string, stor: storage): return_ => {
const existingPlanet = Big_map.find_opt(planetName, stor);
const planet = Option.unopt_with_error(existingPlanet, "Unknown planet cannot be destroyed");
const senderAddress = Tezos.get_sender();
if (!Option.is_some(planet.lord) || !Tezos.address_equals(senderAddress, Option.unopt(planet.lord))) {
failwith("Only the lord of the planet can destroy it");
}
const updatedStorage = Big_map.remove(planetName, stor);
const updatedStorage = Big_map.update(associationName, Some(updatedAssociation), storage);
return [list([]), updatedStorage];
};
*/
const noOperations: list<operation> = [];
const result: return_ = [noOperations, updatedStorage];
return result;
}
//List associations
//List associations
@view
@view
...
...
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