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

Checking for the decimals on the feeToken

This commit is contained in:
Jamie Hewitt 2023-07-06 14:06:47 +03:00
parent ae2ff1ccde
commit ece4883743
2 changed files with 20 additions and 2 deletions

View File

@ -30,6 +30,7 @@
"mocha": "TS_NODE_PROJECT='./test/tsconfig.json' mocha --config=test/.mocharc.json --node-env=test --exit",
"test": "npm run lint && npm run test:unit:cover && npm run test:integration:cover",
"test:unit": "npm run mocha -- 'test/unit/**/*.test.ts'",
"test:fixed": "npm run mocha -- 'test/unit/FixedRateExchange.test.ts'",
"test:integration": "npm run mocha -- 'test/integration/**/*.test.ts'",
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
"test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration",

View File

@ -1,6 +1,13 @@
import { BigNumber } from 'ethers'
import ERC721Factory from '@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json'
import { generateDtName, ZERO_ADDRESS, sendTx, getEventFromTx } from '../utils'
import {
generateDtName,
ZERO_ADDRESS,
sendTx,
getEventFromTx,
getTokenDecimals,
LoggerInstance
} from '../utils'
import {
AbiItem,
FreCreationParams,
@ -553,6 +560,16 @@ export class NftFactory extends SmartContractWithAddress {
if (!dtParams.name || !dtParams.symbol) {
;({ name, symbol } = generateDtName())
}
let feeTokenDecimals = 18
if (dtParams.feeToken !== ZERO_ADDRESS) {
try {
feeTokenDecimals = await getTokenDecimals(this.signer, dtParams.feeToken)
} catch (error) {
LoggerInstance.error('getTokenDecimals error', error)
}
}
return {
templateIndex: dtParams.templateIndex,
strings: [dtParams.name || name, dtParams.symbol || symbol],
@ -564,7 +581,7 @@ export class NftFactory extends SmartContractWithAddress {
],
uints: [
await this.amountToUnits(null, dtParams.cap, 18),
await this.amountToUnits(null, dtParams.feeAmount, 18)
await this.amountToUnits(null, dtParams.feeAmount, feeTokenDecimals)
],
bytess: []
}