diff --git a/package.json b/package.json index 3db1e867..668c2acf 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/contracts/NFTFactory.ts b/src/contracts/NFTFactory.ts index d63ea78f..86a736ae 100644 --- a/src/contracts/NFTFactory.ts +++ b/src/contracts/NFTFactory.ts @@ -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: [] }