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

update call

parent e387d6ad
No related branches found
No related tags found
No related merge requests found
......@@ -7,10 +7,13 @@ import { askQuestion } from '../utils/askQuestion.js';
// IMPORT TYPES
import { Association } from '../types/Association.js';
import { Proposal } from '../types/Proposal.js';
// IMPORT SERVICES
import { getBalance } from '../services/balance.service.js';
import { createAssociation } from '../services/association.service.js';
import { createAssociation, joinAssociation } from '../services/association.service.js';
import { createProposal } from '../services/proposal.service.js';
import { createFA21Contract } from '../services/contract.service.js';
async function handleCreateAsssociation(tezos: TezosToolkit) {
const name = await askQuestion(chalk.yellow('Nom: '));
......@@ -20,34 +23,66 @@ async function handleCreateAsssociation(tezos: TezosToolkit) {
description: description
};
console.log("Création du token en cours...");
console.log("Création de l'association en cours...");
try {
const op = await createAssociation(association, tezos);
console.log(op.hash);
console.log(chalk.green("\nVotre association a été crée !!\n"));
} catch {
console.log("Erreur lors de la création du token");
console.log("Erreur lors de la création de l'association");
}
}
async function handleCreateToken(tezos: TezosToolkit) {
const nbTokenFungible = await askQuestion(chalk.yellow('Nombre de token fongible: '));
// Faire le call pour créer un token
console.log(chalk.green("\nVotre token a été créé !!\n"));
const nbTokenFungible: string = await askQuestion(chalk.yellow('Nombre de token fongible: '));
try {
const op = await createFA21Contract(nbTokenFungible, tezos);
console.log(op.hash);
console.log(chalk.green("\nVotre token a été créé !!\n"));
} catch {
console.log("Erreur lors de la création du token");
}
}
async function handleGetBalance(tezos: TezosToolkit) {
const balance = await getBalance(tezos);
console.log(`\nSolde du portefeuille: ${balance} ꜩ\n`);
try {
const balance = await getBalance(tezos);
console.log(`\nSolde du portefeuille: ${balance} ꜩ\n`);
} catch {
console.log("Erreur lors de la récupération de votre portefeuille");
}
}
async function handleCreateProposal(tezos: TezosToolkit) {
const title = await askQuestion(chalk.yellow('Titre: '));
const description = await askQuestion(chalk.yellow('Description: '));
const proposal: Proposal = {
title: title,
description: description
};
try {
console.log("Création de la proposition en cours...");
const op = await createProposal(proposal, tezos);
console.log(op.hash);
console.log(chalk.green("\nVous avez soumis une proposition !!\n"));
// Faire l'appel a post proposal association
} catch {
console.log("Erreur lors de la création de la proposition");
}
}
async function handleJoinAssociation(tezos: TezosToolkit) {
const name = await askQuestion(chalk.yellow("Nom de l'association: "));
const name = await askQuestion(chalk.yellow("Nom de l'association: "));
try {
console.log("Inscription à l'association en cours...");
const op = await joinAssociation(name, tezos);
console.log(op.hash);
console.log(chalk.green("\nVous avez soumis une proposition !!\n"));
} catch {
console.log("Erreur lors de l'inscription à l'association");
}
console.log(chalk.green("\nVous avez rejoint l'association !!\n"));
}
......
......@@ -4,9 +4,9 @@ import { Operation, TezosToolkit } from '@taquito/taquito';
const address = "KT1QZJzhSPQ89K4eC59tmQYCt44qph7wXoJu"
// NEED UPDATE ENTRYPOINT !!
async function createFA21Contract(tezos: TezosToolkit): Promise<Operation> {
async function createFA21Contract(nbTokenFongible: string, tezos: TezosToolkit): Promise<Operation> {
const contract = await tezos.contract.at(address);
const op: Operation = await contract.methodsObject.createFA21Contract().send();
const op: Operation = await contract.methodsObject.createFA21Contract(nbTokenFongible).send();
await op.confirmation();
return op;
......
export * from "./association.service";
export * from "./balance.service";
export * from "./contract.service";
export * from "./proposal.service";
export * from "./token.service";
\ No newline at end of file
export type Proposal = {
title: string;
description: string;
fct: () => void;
fct?: () => void;
participationRate?: number;
approveRate?: number;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment