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

Merge pull request #1414 from oceanprotocol/issue-1413-refactor-zero-address-constant

Issue-#1413: Refactor ZERO_ADDRESS constant
This commit is contained in:
Miquel A. Cabot 2022-04-12 09:41:10 +02:00 committed by GitHub
commit 21a7b739f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 24 deletions

View File

@ -11,7 +11,8 @@ import {
getErcCreationParams,
getPoolCreationParams,
configHelperNetworks,
setContractDefaults
setContractDefaults,
ZERO_ADDRESS
} from '../utils'
import { Config } from '../models/index.js'
import {
@ -45,7 +46,6 @@ export interface NftCreateData {
owner: string
}
const addressZERO = '0x0000000000000000000000000000000000000000'
/**
* Provides an interface for NFT Factory contract
*/
@ -94,8 +94,8 @@ export class NftFactory {
nftData.name,
nftData.symbol,
nftData.templateIndex,
addressZERO,
addressZERO,
ZERO_ADDRESS,
ZERO_ADDRESS,
nftData.tokenURI,
nftData.transferable,
nftData.owner
@ -139,8 +139,8 @@ export class NftFactory {
nftData.name,
nftData.symbol,
nftData.templateIndex,
addressZERO,
addressZERO,
ZERO_ADDRESS,
ZERO_ADDRESS,
nftData.tokenURI,
nftData.transferable,
nftData.owner
@ -278,7 +278,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`)
}
@ -445,7 +445,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`)
}

View File

@ -9,7 +9,8 @@ import {
configHelperNetworks,
setContractDefaults,
amountToUnits,
unitsToAmount
unitsToAmount,
ZERO_ADDRESS
} from '../../utils'
import { Config } from '../../models/index.js'
import { PriceAndFees } from '../..'
@ -164,7 +165,7 @@ export class FixedRateExchange {
exchangeId: string,
datatokenAmount: string,
maxBaseTokenAmount: string,
consumeMarketAddress: string = '0x0000000000000000000000000000000000000000',
consumeMarketAddress: string = ZERO_ADDRESS,
consumeMarketFee: string = '0'
): Promise<TransactionReceipt> {
const exchange = await this.getExchange(exchangeId)
@ -260,7 +261,7 @@ export class FixedRateExchange {
exchangeId: string,
datatokenAmount: string,
minBaseTokenAmount: string,
consumeMarketAddress: string = '0x0000000000000000000000000000000000000000',
consumeMarketAddress: string = ZERO_ADDRESS,
consumeMarketFee: string = '0'
): Promise<TransactionReceipt> {
const exchange = await this.getExchange(exchangeId)

View File

@ -10,7 +10,8 @@ import {
getFairGasPrice,
setContractDefaults,
configHelperNetworks,
getFreOrderParams
getFreOrderParams,
ZERO_ADDRESS
} from '../utils'
import {
ConsumeMarketFee,
@ -206,8 +207,7 @@ export class Datatoken {
const gasLimitDefault = this.GASLIMIT_DEFAULT
if (!fixedRateParams.allowedConsumer)
fixedRateParams.allowedConsumer = '0x0000000000000000000000000000000000000000'
if (!fixedRateParams.allowedConsumer) fixedRateParams.allowedConsumer = ZERO_ADDRESS
const withMint = fixedRateParams.withMint ? 1 : 0
let estGas
@ -257,8 +257,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
@ -320,8 +319,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
@ -367,8 +365,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
@ -975,8 +972,8 @@ export class Datatoken {
)
if (!consumeMarketFee) {
consumeMarketFee = {
consumeMarketFeeAddress: '0x0000000000000000000000000000000000000000',
consumeMarketFeeToken: '0x0000000000000000000000000000000000000000',
consumeMarketFeeAddress: ZERO_ADDRESS,
consumeMarketFeeToken: ZERO_ADDRESS,
consumeMarketFeeAmount: '0'
}
}

View File

@ -11,6 +11,7 @@ import {
import { Config } from '../models'
import { minAbi } from './minAbi'
import LoggerInstance from './Logger'
import { ZERO_ADDRESS } from './Constants'
export function setContractDefaults(contract: Contract, config: Config): Contract {
if (config) {
@ -65,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 {