From 46ed66ef8224712e6e42422952e9dd495c486757 Mon Sep 17 00:00:00 2001 From: Liviu Vlad Date: Sun, 4 Feb 2024 00:14:15 +0200 Subject: [PATCH] #125 send implementation of split voucher --- .../smart-contract/smart-contract.service.ts | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/modules/smart-contract/smart-contract.service.ts b/src/modules/smart-contract/smart-contract.service.ts index e233069..acb9430 100644 --- a/src/modules/smart-contract/smart-contract.service.ts +++ b/src/modules/smart-contract/smart-contract.service.ts @@ -58,13 +58,11 @@ export class SmartContractService { .send({ from: this.wiiQareAccount.address, gasPrice: gasPrice, - gas: 500000 + gas: 500000, }); logInfo(`response -> ${response}`); - - return response; } catch (err) { logError(`Error in mintVoucher: ${err}`); @@ -154,7 +152,7 @@ export class SmartContractService { .call({ from: this.wiiQareAccount.address, gasPrice: gasPrice, - gas: 500000 + gas: 500000, }); return result; @@ -163,7 +161,6 @@ export class SmartContractService { } } - /** * This function is used to make a voucher split * ** splitVoucher @@ -174,12 +171,14 @@ export class SmartContractService { */ async splitVoucher(voucherID: string, firstVoucher: any, secondVoucher: any) { try { - const accounts = await this.web3.eth.getAccounts(); - + const gasPrice = await this.web3.eth.getGasPrice(); const result = await this.wiiqareContract.methods .splitVoucher(voucherID, firstVoucher, secondVoucher) - .call({ from: accounts[0] }); - + .send({ + from: this.wiiQareAccount.address, + gasPrice: gasPrice, + gas: 500000, + }); return result; } catch (err) { logError(`Error in getVoucher: ${err}`); @@ -192,15 +191,11 @@ export class SmartContractService { ); const gasPrice = await this.web3.eth.getGasPrice(); - const response = await this.wiiqareContract.methods - .burn( - voucherID - ) - .send({ - from: this.wiiQareAccount.address, - gasPrice: gasPrice, - gas: 500000 - }); + const response = await this.wiiqareContract.methods.burn(voucherID).send({ + from: this.wiiQareAccount.address, + gasPrice: gasPrice, + gas: 500000, + }); logInfo(`response -> ${response}`);