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
2d1cf893
Commit
2d1cf893
authored
1 year ago
by
Lydia Tarmelit
Browse files
Options
Downloads
Patches
Plain Diff
deploy and set story 1 , 2 , 3 ,4
parent
34817b3b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
contracts/AssociationRegistry.jsligo
+29
-37
29 additions, 37 deletions
contracts/AssociationRegistry.jsligo
deploy/.env
+3
-2
3 additions, 2 deletions
deploy/.env
with
32 additions
and
39 deletions
contracts/AssociationRegistry.jsligo
+
29
−
37
View file @
2d1cf893
...
...
@@ -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 = {
a
ssociation
s
:
updatedA
ssociation
s,
associationNames: updatedA
ssociation
Names
// Deduct registration fee from wallet amount and create new association
const newA
ssociation:
a
ssociation
= {
...a
ssociation
,
};
// 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
This diff is collapsed.
Click to expand it.
deploy/.env
+
3
−
2
View file @
2d1cf893
# 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
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