mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
Merge branch 'main' into fix/fixedPrice
This commit is contained in:
commit
84e28fda91
@ -22,7 +22,7 @@ interface UsePricing {
|
|||||||
) => Promise<TransactionReceipt | string | void>
|
) => Promise<TransactionReceipt | string | void>
|
||||||
buyDT: (dtAmount: number | string) => Promise<TransactionReceipt | void>
|
buyDT: (dtAmount: number | string) => Promise<TransactionReceipt | void>
|
||||||
sellDT: (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
|
pricingStep?: number
|
||||||
pricingStepText?: string
|
pricingStepText?: string
|
||||||
pricingError?: string
|
pricingError?: string
|
||||||
@ -83,10 +83,23 @@ function usePricing(ddo: DDO): UsePricing {
|
|||||||
setPricingStepText(messages[index])
|
setPricingStepText(messages[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mint(tokensToMint: string): Promise<TransactionReceipt> {
|
async function mint(
|
||||||
|
tokensToMint: string
|
||||||
|
): Promise<TransactionReceipt | void> {
|
||||||
Logger.log('mint function', dataToken, accountId)
|
Logger.log('mint function', dataToken, accountId)
|
||||||
const tx = await ocean.datatokens.mint(dataToken, accountId, tokensToMint)
|
const balance = new Decimal(
|
||||||
return tx
|
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(
|
async function buyDT(
|
||||||
|
Loading…
Reference in New Issue
Block a user