From 0cdb4220e9415b09116dc9056f4cf4ea7c6fe6fe Mon Sep 17 00:00:00 2001
From: Nawfel Senoussi <nawfelsen@mbp-de-nawfel.home>
Date: Mon, 1 Apr 2024 16:17:37 +0200
Subject: [PATCH] update jsdoc

---
 package-lock.json                             | 11 +---------
 package.json                                  |  3 +--
 src/features/association/createAssociation.ts |  5 +++++
 src/features/association/joinAssociation.ts   |  7 +++++-
 .../association/showAssociationDetails.ts     |  7 +++++-
 src/features/association/showAssociations.ts  |  7 +++++-
 src/features/balance/showBalance.ts           |  5 +++++
 src/features/proposal/closeProposal.ts        |  7 +++++-
 src/features/proposal/createProposal.ts       |  5 +++++
 src/features/proposal/resolveProposal.ts      |  7 +++++-
 src/features/proposal/showProposals.ts        |  7 +++++-
 src/features/proposal/voteProposal.ts         |  7 +++++-
 src/features/token/burnToken.ts               |  5 +++++
 src/features/token/createToken.ts             |  5 +++++
 .../association/associationHandlers.ts        |  7 +++---
 src/handlers/proposal/proposalHandlers.ts     | 17 +++++++-------
 src/utils/getRole.ts                          |  2 +-
 .../association/associationHandlers.spec.ts   | 10 +++++++--
 .../proposal/proposalHandlers.spec.ts         | 22 +++++++++++++++----
 19 files changed, 107 insertions(+), 39 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index cef7a34..11c545e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,8 +16,7 @@
         "commander": "^12.0.0",
         "figlet": "^1.7.0",
         "inquirer": "^9.2.16",
-        "ts-node": "^10.9.2",
-        "tsc": "^2.0.4"
+        "ts-node": "^10.9.2"
       },
       "devDependencies": {
         "@types/commander": "^2.12.2",
@@ -5464,14 +5463,6 @@
         }
       }
     },
-    "node_modules/tsc": {
-      "version": "2.0.4",
-      "resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz",
-      "integrity": "sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q==",
-      "bin": {
-        "tsc": "bin/tsc"
-      }
-    },
     "node_modules/tsconfig-paths": {
       "version": "3.15.0",
       "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz",
diff --git a/package.json b/package.json
index 41c0364..1017584 100644
--- a/package.json
+++ b/package.json
@@ -20,8 +20,7 @@
     "commander": "^12.0.0",
     "figlet": "^1.7.0",
     "inquirer": "^9.2.16",
-    "ts-node": "^10.9.2",
-    "tsc": "^2.0.4"
+    "ts-node": "^10.9.2"
   },
   "devDependencies": {
     "@types/commander": "^2.12.2",
diff --git a/src/features/association/createAssociation.ts b/src/features/association/createAssociation.ts
index 3af3c0c..bee8133 100644
--- a/src/features/association/createAssociation.ts
+++ b/src/features/association/createAssociation.ts
@@ -2,6 +2,11 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleCreateAssociation } from '../../handlers/association/associationHandlers.js'
 
+/**
+ * Creates an association.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the association is created.
+ */
 async function createAssociation (tezos: TezosToolkit): Promise<void> {
   await handleCreateAssociation(tezos).then(() => {
     console.log(chalk.bgGreenBright('\nVotre association a été créée !!'))
diff --git a/src/features/association/joinAssociation.ts b/src/features/association/joinAssociation.ts
index 5222356..47ab943 100644
--- a/src/features/association/joinAssociation.ts
+++ b/src/features/association/joinAssociation.ts
@@ -2,9 +2,14 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleGetAssociations, handleJoinAssociation } from '../../handlers/association/associationHandlers.js'
 
+/**
+ * Joins an association.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the user joins the association.
+ */
 async function joinAssociation (tezos: TezosToolkit): Promise<void> {
   await handleGetAssociations(tezos).then(async (response) => {
-    const associationsByName: string[] = response
+    const associationsByName: string[] = response.map(association => association.name)
 
     await handleJoinAssociation(associationsByName, tezos).then(() => {
       console.log(chalk.bgGreenBright("\nVous avez rejoint l'association !!"))
diff --git a/src/features/association/showAssociationDetails.ts b/src/features/association/showAssociationDetails.ts
index dc53987..9ec9d33 100644
--- a/src/features/association/showAssociationDetails.ts
+++ b/src/features/association/showAssociationDetails.ts
@@ -2,9 +2,14 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleGetAssociationDetails, handleGetAssociations } from '../../handlers/association/associationHandlers.js'
 
+/**
+ * Displays details of association.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the association details are displayed.
+ */
 async function showAssociationDetails (tezos: TezosToolkit): Promise<void> {
   await handleGetAssociations(tezos).then(async (response) => {
-    const associationsByName = response
+    const associationsByName = response.map(association => association.name)
 
     if (response.length === 0) throw new Error('Aucune association existante')
 
diff --git a/src/features/association/showAssociations.ts b/src/features/association/showAssociations.ts
index 74e24ad..751c320 100644
--- a/src/features/association/showAssociations.ts
+++ b/src/features/association/showAssociations.ts
@@ -2,9 +2,14 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleGetAssociations } from '../../handlers/association/associationHandlers.js'
 
+/**
+ * Displays associations.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the associations are displayed.
+ */
 async function showAssociations (tezos: TezosToolkit): Promise<void> {
   await handleGetAssociations(tezos).then((response) => {
-    const associationsByName = response
+    const associationsByName = response.map(association => association.name)
 
     if (response.length === 0) throw new Error('Aucune association existante')
 
diff --git a/src/features/balance/showBalance.ts b/src/features/balance/showBalance.ts
index 91057fe..764688e 100644
--- a/src/features/balance/showBalance.ts
+++ b/src/features/balance/showBalance.ts
@@ -2,6 +2,11 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleGetBalance } from '../../handlers/balance/balanceHandlers.js'
 
+/**
+ * Displays the balance of the wallet.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the balance is displayed.
+ */
 async function showBalance (tezos: TezosToolkit): Promise<void> {
   await handleGetBalance(tezos).then((response) => {
     console.log(`\nSolde du portefeuille: ${response} ꜩ`)
diff --git a/src/features/proposal/closeProposal.ts b/src/features/proposal/closeProposal.ts
index 4a0743f..0a69fc9 100644
--- a/src/features/proposal/closeProposal.ts
+++ b/src/features/proposal/closeProposal.ts
@@ -2,9 +2,14 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleGetOpenProposals, handleCloseProposal } from '../../handlers/proposal/proposalHandlers.js'
 
+/**
+ * Closes a proposal
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the proposal is closed.
+ */
 async function closeProposal (tezos: TezosToolkit): Promise<void> {
   await handleGetOpenProposals(tezos).then(async (response) => {
-    const proposalsByTitle: string[] = response
+    const proposalsByTitle: string[] = response.map(proposal => proposal.title)
 
     if (response.length === 0) throw new Error("Aucune proposition n'est ouverte")
 
diff --git a/src/features/proposal/createProposal.ts b/src/features/proposal/createProposal.ts
index 0056904..1e33231 100644
--- a/src/features/proposal/createProposal.ts
+++ b/src/features/proposal/createProposal.ts
@@ -2,6 +2,11 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleCreateProposal } from '../../handlers/proposal/proposalHandlers.js'
 
+/**
+ * Creates a proposal.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the proposal is created.
+ */
 async function createProposal (tezos: TezosToolkit): Promise<void> {
   await handleCreateProposal(tezos).then(() => {
     console.log(chalk.bgGreenBright('\nVous avez soumis une proposition !!'))
diff --git a/src/features/proposal/resolveProposal.ts b/src/features/proposal/resolveProposal.ts
index a61360e..6e2c1ab 100644
--- a/src/features/proposal/resolveProposal.ts
+++ b/src/features/proposal/resolveProposal.ts
@@ -2,9 +2,14 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleGetSolvableProposals, handleResolveProposal } from '../../handlers/proposal/proposalHandlers.js'
 
+/**
+ * Resolves a proposal.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the proposal is resolved.
+ */
 async function resolveProposal (tezos: TezosToolkit): Promise<void> {
   await handleGetSolvableProposals(tezos).then(async (response) => {
-    const proposalsByTitle: string[] = response
+    const proposalsByTitle: string[] = response.map(proposal => proposal.title)
 
     if (response.length === 0) throw new Error("Aucune proposition n'est résoluble")
 
diff --git a/src/features/proposal/showProposals.ts b/src/features/proposal/showProposals.ts
index c85dda0..3336cb5 100644
--- a/src/features/proposal/showProposals.ts
+++ b/src/features/proposal/showProposals.ts
@@ -2,9 +2,14 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleGetProposals } from '../../handlers/proposal/proposalHandlers.js'
 
+/**
+ * Displays proposals.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the proposals are displayed.
+ */
 async function showProposals (tezos: TezosToolkit): Promise<void> {
   await handleGetProposals(tezos).then((response) => {
-    const proposalsByTitle = response
+    const proposalsByTitle = response.map(proposal => proposal.title)
 
     if (response.length === 0) throw new Error('Aucune proposition existante')
 
diff --git a/src/features/proposal/voteProposal.ts b/src/features/proposal/voteProposal.ts
index fd6ec9e..cdd1019 100644
--- a/src/features/proposal/voteProposal.ts
+++ b/src/features/proposal/voteProposal.ts
@@ -2,9 +2,14 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleGetOpenProposals, handleVoteProposal } from '../../handlers/proposal/proposalHandlers.js'
 
+/**
+ * Votes for a proposal.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the vote is submitted.
+ */
 async function voteProposal (tezos: TezosToolkit): Promise<void> {
   await handleGetOpenProposals(tezos).then(async (response) => {
-    const proposalsByTitle: string[] = response
+    const proposalsByTitle: string[] = response.map(proposal => proposal.title)
 
     if (response.length === 0) throw new Error("Aucune proposition n'est ouverte")
 
diff --git a/src/features/token/burnToken.ts b/src/features/token/burnToken.ts
index e301093..98060c4 100644
--- a/src/features/token/burnToken.ts
+++ b/src/features/token/burnToken.ts
@@ -2,6 +2,11 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleBurnToken } from '../../handlers/token/tokenHandlers.js'
 
+/**
+ * Burns tokens.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the tokens are burned.
+ */
 async function burnToken (tezos: TezosToolkit): Promise<void> {
   await handleBurnToken(tezos).then(() => {
     console.log(chalk.bgGreenBright('\nVous avez bruler vos tokens !!'))
diff --git a/src/features/token/createToken.ts b/src/features/token/createToken.ts
index 478106f..cf69113 100644
--- a/src/features/token/createToken.ts
+++ b/src/features/token/createToken.ts
@@ -2,6 +2,11 @@ import { type TezosToolkit } from '@taquito/taquito'
 import chalk from 'chalk'
 import { handleCreateToken } from '../../handlers/token/tokenHandlers.js'
 
+/**
+ * Creates a token.
+ * @param {TezosToolkit} tezos - The instance of the Tezos toolkit.
+ * @returns {Promise<void>} A promise resolved once the token is created.
+ */
 async function createToken (tezos: TezosToolkit): Promise<void> {
   await handleCreateToken(tezos).then(() => {
     console.log(chalk.bgGreenBright('\nVotre token a été créé !!'))
diff --git a/src/handlers/association/associationHandlers.ts b/src/handlers/association/associationHandlers.ts
index f7f4db3..431f061 100644
--- a/src/handlers/association/associationHandlers.ts
+++ b/src/handlers/association/associationHandlers.ts
@@ -95,12 +95,11 @@ async function handleJoinAssociation (associations: string[], tezos: TezosToolki
 /**
  * Handles the process of listing associations.
  * @param {TezosToolkit} tezos - The TezosToolkit instance used for blockchain operations.
- * @returns {Promise<string[]>} A promise with a list of string of association name.
+ * @returns {Promise<Association[]>} A promise with a list of string of association name.
  */
-async function handleGetAssociations (tezos: TezosToolkit): Promise<string[]> {
+async function handleGetAssociations (tezos: TezosToolkit): Promise<Association[]> {
   try {
-    const associations = await getAssociations(tezos)
-    return associations.map(association => association.name)
+    return await getAssociations(tezos)
   } catch (error) {
     const errorMessage = error.message ? error.message : 'Unknown error occurred'
     throw new Error(`${errorMessage}`)
diff --git a/src/handlers/proposal/proposalHandlers.ts b/src/handlers/proposal/proposalHandlers.ts
index 6e92e1a..9b85ebd 100644
--- a/src/handlers/proposal/proposalHandlers.ts
+++ b/src/handlers/proposal/proposalHandlers.ts
@@ -128,10 +128,9 @@ async function handleCloseProposal (proposals: string[], tezos: TezosToolkit): P
  * @param {TezosToolkit} tezos - The TezosToolkit instance used for blockchain operations.
  * @returns {Promise<Proposal[]>} A promise with a list of proposal title.
  */
-async function handleGetProposals (tezos: TezosToolkit): Promise<string[]> {
+async function handleGetProposals (tezos: TezosToolkit): Promise<Proposal[]> {
   try {
-    const proposals: Proposal[] = await getProposals(tezos)
-    return proposals.map(proposal => proposal.title)
+    return await getProposals(tezos)
   } catch (error) {
     const errorMessage = error.message ? error.message : 'Unknown error occurred'
     throw new Error(`${errorMessage}`)
@@ -141,12 +140,12 @@ async function handleGetProposals (tezos: TezosToolkit): Promise<string[]> {
 /**
  * Handles the process of listing open proposals.
  * @param {TezosToolkit} tezos - The TezosToolkit instance used for blockchain operations.
- * @returns {Promise<string[]>} A promise with a list of open proposal title.
+ * @returns {Promise<Proposal[]>} A promise with a list of open proposal title.
  */
-async function handleGetOpenProposals (tezos: TezosToolkit): Promise<string[]> {
+async function handleGetOpenProposals (tezos: TezosToolkit): Promise<Proposal[]> {
   try {
     const proposals: Proposal[] = await getProposals(tezos)
-    return proposals.filter(proposal => proposal.isOpen).map(proposal => proposal.title)
+    return proposals.filter(proposal => proposal.isOpen)
   } catch (error) {
     const errorMessage = error.message ? error.message : 'Unknown error occurred'
     throw new Error(`${errorMessage}`)
@@ -156,12 +155,12 @@ async function handleGetOpenProposals (tezos: TezosToolkit): Promise<string[]> {
 /**
  * Handles the process of listing solvable proposals.
  * @param {TezosToolkit} tezos - The TezosToolkit instance used for blockchain operations.
- * @returns {Promise<string[]>} A promise with a list of solvable proposal title.
+ * @returns {Promise<Proposal[]>} A promise with a list of solvable proposal title.
  */
-async function handleGetSolvableProposals (tezos: TezosToolkit): Promise<string[]> {
+async function handleGetSolvableProposals (tezos: TezosToolkit): Promise<Proposal[]> {
   try {
     const proposals: Proposal[] = await getProposals(tezos)
-    return proposals.filter(proposal => proposal.approveRate >= 51).map(proposal => proposal.title)
+    return proposals.filter(proposal => proposal.approveRate >= 51)
   } catch (error) {
     const errorMessage = error.message ? error.message : 'Unknown error occurred'
     throw new Error(`${errorMessage}`)
diff --git a/src/utils/getRole.ts b/src/utils/getRole.ts
index d6de12f..ea17ad8 100644
--- a/src/utils/getRole.ts
+++ b/src/utils/getRole.ts
@@ -8,5 +8,5 @@ export async function getRole (tezos: TezosToolkit): Promise<Role> {
   // if (isAdmin) return 'ADMIN'
 
   // TEMPORARY
-  return 'CONNECTED'
+  return 'ADHERENT'
 }
diff --git a/test/handlers/association/associationHandlers.spec.ts b/test/handlers/association/associationHandlers.spec.ts
index fa5210c..1b5b1d3 100644
--- a/test/handlers/association/associationHandlers.spec.ts
+++ b/test/handlers/association/associationHandlers.spec.ts
@@ -131,8 +131,14 @@ describe('associationHandlers', () => {
         expect(getAssociationsSpy).toBeCalledWith(mockedTezosToolkit)
         expect(associations).toStrictEqual(
           [
-            'Association 1',
-            'Association 2'
+            {
+              description: 'Association 1 description',
+              name: 'Association 1'
+            },
+            {
+              description: 'Association 2 description',
+              name: 'Association 2'
+            }
           ]
         )
       })
diff --git a/test/handlers/proposal/proposalHandlers.spec.ts b/test/handlers/proposal/proposalHandlers.spec.ts
index 7785c33..e7115cd 100644
--- a/test/handlers/proposal/proposalHandlers.spec.ts
+++ b/test/handlers/proposal/proposalHandlers.spec.ts
@@ -159,8 +159,14 @@ describe('proposalHandlers', () => {
         expect(getProposalsSpy).toBeCalledWith(mockedTezosToolkit)
         expect(proposals).toStrictEqual(
           [
-            'Proposal 1',
-            'Proposal 2'
+            {
+              description: 'Proposal 1 description',
+              title: 'Proposal 1'
+            },
+            {
+              description: 'Proposal 2 description',
+              title: 'Proposal 2'
+            }
           ]
         )
       })
@@ -198,7 +204,11 @@ describe('proposalHandlers', () => {
         expect(getProposalsSpy).toBeCalledWith(mockedTezosToolkit)
         expect(proposals).toStrictEqual(
           [
-            'Proposal 1'
+            {
+              description: 'Proposal 1 description',
+              isOpen: true,
+              title: 'Proposal 1'
+            }
           ]
         )
       })
@@ -236,7 +246,11 @@ describe('proposalHandlers', () => {
         expect(getProposalsSpy).toBeCalledWith(mockedTezosToolkit)
         expect(proposals).toStrictEqual(
           [
-            'Proposal 2'
+            {
+              approveRate: 51,
+              description: 'Proposal 2 description',
+              title: 'Proposal 2'
+            }
           ]
         )
       })
-- 
GitLab