Skip to content
Snippets Groups Projects
Commit 985bd37e authored by Andri Joos's avatar Andri Joos :blush:
Browse files

marketplace sell

parent a0ef1d88
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,6 @@ namespace Frontend.Marketplaces.Interfaces ...@@ -11,6 +11,6 @@ namespace Frontend.Marketplaces.Interfaces
public Task<double> PotatoKgPriceInEth { get; } public Task<double> PotatoKgPriceInEth { get; }
public Task<bool> Approve(Web3 approverClient, BigInteger amount); public Task<bool> Approve(Web3 approverClient, BigInteger amount);
public Task<PotatoTransaction?> Buy(string ownerAddress); public Task<PotatoTransaction?> Buy(string ownerAddress);
// public double Sell(PotatoTransaction transaction); public Task<bool> Sell(PotatoTransaction transaction, string receiverAddress);
} }
} }
...@@ -69,6 +69,21 @@ public class PotatoMarketplaceMock( ...@@ -69,6 +69,21 @@ public class PotatoMarketplaceMock(
}; };
} }
public async Task<bool> Sell(PotatoTransaction transaction, string receiverAddress)
{
var amount = (double)await PotatoKgWeiPrice() * transaction.Weight;
var transferHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>();
var transferFunction = new TransferFunction
{
To = receiverAddress,
Value = new BigInteger(amount),
};
var receipt = await transferHandler.SendRequestAndWaitForReceiptAsync(wethAddress, transferFunction);
return receipt.Status.Value == 1;
}
private static async Task<double> EthChfPrice() private static async Task<double> EthChfPrice()
{ {
string url = "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=CHF"; string url = "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=CHF";
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment