From ea74e4fc384e3da02d5ad53d9c90b8a06db03660 Mon Sep 17 00:00:00 2001 From: "Miquel A. Cabot" Date: Wed, 6 Apr 2022 14:25:34 +0200 Subject: [PATCH] use ZERO_ADDRESS constant --- src/factories/NFTFactory.ts | 20 ++++++++++---------- src/pools/fixedRate/FixedRateExchange.ts | 7 ++++--- src/tokens/Datatoken.ts | 19 ++++++++----------- src/utils/ContractUtils.ts | 5 ++--- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index 6eb5a61a..9f1cb4fa 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -12,7 +12,8 @@ import { getPoolCreationParams, configHelperNetworks, setContractDefaults, - estimateGas + estimateGas, + ZERO_ADDRESS } from '../utils' import { Config } from '../models/index.js' import { @@ -46,7 +47,6 @@ export interface NftCreateData { owner: string } -const addressZERO = '0x0000000000000000000000000000000000000000' /** * Provides an interface for NFT Factory contract */ @@ -92,8 +92,8 @@ export class NftFactory { nftData.name, nftData.symbol, nftData.templateIndex, - addressZERO, - addressZERO, + ZERO_ADDRESS, + ZERO_ADDRESS, nftData.tokenURI ) } @@ -128,8 +128,8 @@ export class NftFactory { nftData.name, nftData.symbol, nftData.templateIndex, - addressZERO, - addressZERO, + ZERO_ADDRESS, + ZERO_ADDRESS, nftData.tokenURI ) @@ -139,8 +139,8 @@ export class NftFactory { nftData.name, nftData.symbol, nftData.templateIndex, - addressZERO, - addressZERO, + ZERO_ADDRESS, + ZERO_ADDRESS, nftData.tokenURI ) .send({ @@ -271,7 +271,7 @@ export class NftFactory { if ((await this.getOwner()) !== address) { throw new Error(`Caller is not Factory Owner`) } - if (templateAddress === addressZERO) { + if (templateAddress === ZERO_ADDRESS) { throw new Error(`Template cannot be ZERO address`) } @@ -430,7 +430,7 @@ export class NftFactory { if ((await this.getOwner()) !== address) { throw new Error(`Caller is not Factory Owner`) } - if (templateAddress === addressZERO) { + if (templateAddress === ZERO_ADDRESS) { throw new Error(`Template cannot be address ZERO`) } diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 7af3906b..ea67fe61 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -10,7 +10,8 @@ import { setContractDefaults, amountToUnits, unitsToAmount, - estimateGas + estimateGas, + ZERO_ADDRESS } from '../../utils' import { Config } from '../../models/index.js' import { PriceAndFees } from '../..' @@ -158,7 +159,7 @@ export class FixedRateExchange { exchangeId: string, datatokenAmount: string, maxBaseTokenAmount: string, - consumeMarketAddress: string = '0x0000000000000000000000000000000000000000', + consumeMarketAddress: string = ZERO_ADDRESS, consumeMarketFee: string = '0' ): Promise { const exchange = await this.getExchange(exchangeId) @@ -249,7 +250,7 @@ export class FixedRateExchange { exchangeId: string, datatokenAmount: string, minBaseTokenAmount: string, - consumeMarketAddress: string = '0x0000000000000000000000000000000000000000', + consumeMarketAddress: string = ZERO_ADDRESS, consumeMarketFee: string = '0' ): Promise { const exchange = await this.getExchange(exchangeId) diff --git a/src/tokens/Datatoken.ts b/src/tokens/Datatoken.ts index f9169349..6d6a0fc5 100644 --- a/src/tokens/Datatoken.ts +++ b/src/tokens/Datatoken.ts @@ -11,7 +11,8 @@ import { setContractDefaults, configHelperNetworks, getFreOrderParams, - estimateGas + estimateGas, + ZERO_ADDRESS } from '../utils' import { ConsumeMarketFee, @@ -193,8 +194,7 @@ export class Datatoken { this.config ) - if (!fixedRateParams.allowedConsumer) - fixedRateParams.allowedConsumer = '0x0000000000000000000000000000000000000000' + if (!fixedRateParams.allowedConsumer) fixedRateParams.allowedConsumer = ZERO_ADDRESS const withMint = fixedRateParams.withMint ? 1 : 0 return estimateGas( @@ -237,8 +237,7 @@ export class Datatoken { if (!(await this.isERC20Deployer(dtAddress, address))) { throw new Error(`User is not ERC20 Deployer`) } - if (!fixedRateParams.allowedConsumer) - fixedRateParams.allowedConsumer = '0x0000000000000000000000000000000000000000' + if (!fixedRateParams.allowedConsumer) fixedRateParams.allowedConsumer = ZERO_ADDRESS const withMint = fixedRateParams.withMint ? 1 : 0 @@ -312,8 +311,7 @@ export class Datatoken { this.config ) - if (!dispenserParams.allowedSwapper) - dispenserParams.allowedSwapper = '0x0000000000000000000000000000000000000000' + if (!dispenserParams.allowedSwapper) dispenserParams.allowedSwapper = ZERO_ADDRESS if (!dispenserParams.withMint) dispenserParams.withMint = false @@ -351,8 +349,7 @@ export class Datatoken { this.config ) - if (!dispenserParams.allowedSwapper) - dispenserParams.allowedSwapper = '0x0000000000000000000000000000000000000000' + if (!dispenserParams.allowedSwapper) dispenserParams.allowedSwapper = ZERO_ADDRESS if (!dispenserParams.withMint) dispenserParams.withMint = false @@ -894,8 +891,8 @@ export class Datatoken { ) if (!consumeMarketFee) { consumeMarketFee = { - consumeMarketFeeAddress: '0x0000000000000000000000000000000000000000', - consumeMarketFeeToken: '0x0000000000000000000000000000000000000000', + consumeMarketFeeAddress: ZERO_ADDRESS, + consumeMarketFeeToken: ZERO_ADDRESS, consumeMarketFeeAmount: '0' } } diff --git a/src/utils/ContractUtils.ts b/src/utils/ContractUtils.ts index 6386c303..9721bd08 100644 --- a/src/utils/ContractUtils.ts +++ b/src/utils/ContractUtils.ts @@ -11,7 +11,7 @@ import { import { Config } from '../models' import { minAbi } from './minAbi' import LoggerInstance from './Logger' -import { GASLIMIT_DEFAULT } from './Constants' +import { GASLIMIT_DEFAULT, ZERO_ADDRESS } from './Constants' export function setContractDefaults(contract: Contract, config: Config): Contract { if (config) { @@ -66,8 +66,7 @@ export function getFreOrderParams(freParams: FreOrderParams): any { } export function getFreCreationParams(freParams: FreCreationParams): any { - if (!freParams.allowedConsumer) - freParams.allowedConsumer = '0x0000000000000000000000000000000000000000' + if (!freParams.allowedConsumer) freParams.allowedConsumer = ZERO_ADDRESS const withMint = freParams.withMint ? 1 : 0 return {