Skip to content
Snippets Groups Projects
Commit 0cdb4220 authored by Nawfel Senoussi's avatar Nawfel Senoussi
Browse files

update jsdoc

parent 44b4f616
No related branches found
No related tags found
No related merge requests found
Showing
with 107 additions and 39 deletions
......@@ -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",
......
......@@ -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",
......
......@@ -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 !!'))
......
......@@ -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 !!"))
......
......@@ -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')
......
......@@ -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')
......
......@@ -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} ꜩ`)
......
......@@ -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")
......
......@@ -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 !!'))
......
......@@ -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")
......
......@@ -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')
......
......@@ -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")
......
......@@ -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 !!'))
......
......@@ -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éé !!'))
......
......@@ -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}`)
......
......@@ -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}`)
......
......@@ -8,5 +8,5 @@ export async function getRole (tezos: TezosToolkit): Promise<Role> {
// if (isAdmin) return 'ADMIN'
// TEMPORARY
return 'CONNECTED'
return 'ADHERENT'
}
......@@ -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'
}
]
)
})
......
......@@ -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'
}
]
)
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment