1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-12-23 01:29:49 +01:00

Merge branch 'main' into fix/fixedPrice

This commit is contained in:
mihaisc 2020-10-27 18:32:08 +02:00
commit 84e28fda91
No known key found for this signature in database
GPG Key ID: 4FB0C2329B4C6E29

View File

@ -22,7 +22,7 @@ interface UsePricing {
) => Promise<TransactionReceipt | string | void>
buyDT: (dtAmount: number | string) => Promise<TransactionReceipt | void>
sellDT: (dtAmount: number | string) => Promise<TransactionReceipt | void>
mint: (tokensToMint: string) => Promise<TransactionReceipt>
mint: (tokensToMint: string) => Promise<TransactionReceipt | void>
pricingStep?: number
pricingStepText?: string
pricingError?: string
@ -83,10 +83,23 @@ 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 = new Decimal(
await ocean.datatokens.balance(dataToken, accountId)
)
const tokens = new Decimal(tokensToMint)
if (tokens.greaterThan(balance)) {
const mintAmount = tokens.minus(balance)
const tx = await ocean.datatokens.mint(
dataToken,
accountId,
mintAmount.toString()
)
return tx
}
}
async function buyDT(