1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

style mint method

This commit is contained in:
Bogdan Fazakas 2021-10-21 10:50:55 +03:00
parent 1352a1c5d2
commit 7723208473

View File

@ -41,25 +41,25 @@ export class Datatoken {
/** /**
* Mint * Mint
* @param {String} dataTokenAddress * @param {String} dtAddress Datatoken adress
* @param {String} address * @param {String} address
* @param {String} amount Number of datatokens, as number. Will be converted to wei * @param {String} amount Number of datatokens, as number. Will be converted to wei
* @param {String} toAddress - only if toAddress is different from the minter * @param {String} toAddress - only if toAddress is different from the minter
* @return {Promise<TransactionReceipt>} transactionId * @return {Promise<TransactionReceipt>} transactionId
*/ */
public async mint( public async mint(
dataTokenAddress: string, dtAddress: string,
address: string, address: string,
amount: string, amount: string,
toAddress?: string toAddress?: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const dtContract = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress) const dtContract = new this.web3.eth.Contract(this.datatokensABI, dtAddress)
if ((await this.getDTPermissions(dataTokenAddress, address)).minter != true) { if ((await this.getDTPermissions(dtAddress, address)).minter != true) {
throw new Error(`Caller is not Minter`) throw new Error(`Caller is not Minter`)
} }
const capAvailble = await this.getCap(dataTokenAddress) const capAvailble = await this.getCap(dtAddress)
if (new Decimal(capAvailble).gte(amount)) { if (new Decimal(capAvailble).gte(amount)) {
// Estimate gas cost for mint method // Estimate gas cost for mint method
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT