mirror of
https://github.com/oceanprotocol/react.git
synced 2025-01-25 01:32:08 +01:00
use Decimal
This commit is contained in:
parent
d0d7de83f8
commit
f1934fec3e
@ -87,10 +87,17 @@ function usePricing(ddo: DDO): UsePricing {
|
|||||||
tokensToMint: string
|
tokensToMint: string
|
||||||
): Promise<TransactionReceipt | void> {
|
): Promise<TransactionReceipt | void> {
|
||||||
Logger.log('mint function', dataToken, accountId)
|
Logger.log('mint function', dataToken, accountId)
|
||||||
const balance = await ocean.datatokens.balance(dataToken, accountId)
|
const balance = new Decimal(
|
||||||
if (parseFloat(tokensToMint) > parseFloat(balance)) {
|
await ocean.datatokens.balance(dataToken, accountId)
|
||||||
tokensToMint = String(parseFloat(tokensToMint) - parseFloat(balance))
|
)
|
||||||
const tx = await ocean.datatokens.mint(dataToken, accountId, tokensToMint)
|
const tokens = new Decimal(tokensToMint)
|
||||||
|
if (tokens > balance) {
|
||||||
|
const mintAmount = tokens.minus(balance)
|
||||||
|
const tx = await ocean.datatokens.mint(
|
||||||
|
dataToken,
|
||||||
|
accountId,
|
||||||
|
mintAmount.toString()
|
||||||
|
)
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user