Select Git revision
Forked from
Jean-Marie Place / SCODOC_R6A06
Source project has a limited visibility.
-
leonard_montalbano authoredleonard_montalbano authored
roleHandlers.ts 3.33 KiB
import { type TezosToolkit } from '@taquito/taquito'
import { handleBurnToken, handleCreateAssociation, handleCreateProposal, handleCreateToken, handleGetAssociations, handleGetBalance, handleJoinAssociation } from './handlers'
import chalk from 'chalk'
/**
* Handles fa token administrator actions based on the specified choice.
* @param {string} choice - The administrator's choice.
* @param {TezosToolkit} tezos - The TezosToolkit instance used for blockchain operations.
* @returns {Promise<void>} A promise resolved once the processing is complete.
*/
async function handleAdminFATokenChoice (choice: string, tezos: TezosToolkit): Promise<void> {
switch (choice) {
case '0':
break
case '1':
await handleCreateAssociation(tezos)
break
case '2':
await handleCreateToken(tezos)
break
case '3':
await handleBurnToken(tezos)
break
case '4':
await handleGetBalance(tezos)
break
default:
console.log(chalk.bgRedBright('\nChoix invalide\n'))
break
}
}
/**
* Handles association administrator actions based on the specified choice.
* @param {string} choice - The administrator's choice.
* @param {TezosToolkit} tezos - The TezosToolkit instance used for blockchain operations.
* @returns {Promise<void>} A promise resolved once the processing is complete.
*/
async function handleAdminAssociationChoice (choice: string, tezos: TezosToolkit): Promise<void> {
switch (choice) {
case '0':
break
case '1':
await handleCreateToken(tezos)
break
case '2':
await handleBurnToken(tezos)
break
case '3':
await handleGetBalance(tezos)
break
default:
console.log(chalk.bgRedBright('\nChoix invalide\n'))
break
}
}
/**
* Handles adherent actions based on the specified choice.
* @param {string} choice - The adherent's choice.
* @param {TezosToolkit} tezos - The TezosToolkit instance used for blockchain operations.
* @returns {Promise<void>} A promise resolved once the processing is complete.
*/
async function handleAdherentChoice (choice: string, tezos: TezosToolkit): Promise<void> {
switch (choice) {
case '0':
break
case '1':
await handleCreateProposal(tezos)
break
case '2':
await handleCreateToken(tezos)
break
case '3':
await handleGetBalance(tezos)
break
default:
console.log(chalk.bgRedBright('\nChoix invalide\n'))
break
}
}
/**
* Handles connected actions based on the specified choice.
* @param {string} choice - The connected's choice.
* @param {TezosToolkit} tezos - The TezosToolkit instance used for blockchain operations.
* @returns {Promise<void>} A promise resolved once the processing is complete.
*/
async function handleConnectedChoice (choice: string, tezos: TezosToolkit): Promise<void> {
switch (choice) {
case '0':
break
case '1':
await handleJoinAssociation(tezos)
break
case '2':
await handleCreateToken(tezos)
break
case '3':
await handleGetAssociations(tezos)
break
case '4':
await handleGetBalance(tezos)
break
default:
console.log(chalk.bgRedBright('\nChoix invalide\n'))
break
}
}
export { handleAdminAssociationChoice, handleAdminFATokenChoice, handleAdherentChoice, handleConnectedChoice }