1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-25 11:28:46 +01:00
This commit is contained in:
alexcos20 2020-10-27 09:16:34 -07:00
parent bd15ab144d
commit d0d7de83f8

View File

@ -83,10 +83,16 @@ function usePricing(ddo: DDO): UsePricing {
setPricingStepText(messages[index])
}
async function mint(tokensToMint: string): Promise<TransactionReceipt> {
async function mint(
tokensToMint: string
): Promise<TransactionReceipt | void> {
Logger.log('mint function', dataToken, accountId)
const tx = await ocean.datatokens.mint(dataToken, accountId, tokensToMint)
return tx
const balance = await ocean.datatokens.balance(dataToken, accountId)
if (parseFloat(tokensToMint) > parseFloat(balance)) {
tokensToMint = String(parseFloat(tokensToMint) - parseFloat(balance))
const tx = await ocean.datatokens.mint(dataToken, accountId, tokensToMint)
return tx
}
}
async function buyDT(