Esempio n. 1
0
        public async Task <string> CancelDealAsSeller(string ContractAddress, string PublicKey)
        {   //cancel the contract if the time is over (the buyer didn`t sign in time)
            DappAccount          account          = DappAccountController.openWith[PublicKey];
            SmartContractService deployedContract = new SmartContractService(account, ContractAddress);
            double beforeBalanceETH = await DappAccountController.get_ETH_Balance(PublicKey, PublicKey);

            double beforeBalanceILS = await DappAccountController.get_ILS_Balance(PublicKey, PublicKey);

            double exchangeRate = DappAccountController.getExchangeRate_ETH_To_ILS();
            double afterBalanceETH;
            double afterBalanceILS;
            double feeETH;
            double feeILS;
            bool   isCanceled = false;

            isCanceled = await deployedContract.abort();

            if (isCanceled == true)
            {
                afterBalanceETH = await DappAccountController.get_ETH_Balance(PublicKey, PublicKey);

                afterBalanceILS = await DappAccountController.get_ILS_Balance(PublicKey, PublicKey);

                feeETH = beforeBalanceETH - afterBalanceETH;
                feeILS = beforeBalanceILS - afterBalanceILS;
                ConfirmationRecipt recipt = new ConfirmationRecipt();
                recipt.ContractAddress = ContractAddress;
                recipt.feeETH          = feeETH;
                feeILS        = Math.Truncate(feeILS * 100) / 100; //make the double number to be with 3 digits after dot
                recipt.feeILS = feeILS;
                var ReciptJson = Newtonsoft.Json.JsonConvert.SerializeObject(recipt);
                deleteCanceledOfferBySeller(ContractAddress);
                return(ReciptJson);
            }

            return("Fail");
        }