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:
commit
21a7b739f4
@ -11,7 +11,8 @@ import {
|
|||||||
getErcCreationParams,
|
getErcCreationParams,
|
||||||
getPoolCreationParams,
|
getPoolCreationParams,
|
||||||
configHelperNetworks,
|
configHelperNetworks,
|
||||||
setContractDefaults
|
setContractDefaults,
|
||||||
|
ZERO_ADDRESS
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { Config } from '../models/index.js'
|
import { Config } from '../models/index.js'
|
||||||
import {
|
import {
|
||||||
@ -45,7 +46,6 @@ export interface NftCreateData {
|
|||||||
owner: string
|
owner: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const addressZERO = '0x0000000000000000000000000000000000000000'
|
|
||||||
/**
|
/**
|
||||||
* Provides an interface for NFT Factory contract
|
* Provides an interface for NFT Factory contract
|
||||||
*/
|
*/
|
||||||
@ -94,8 +94,8 @@ export class NftFactory {
|
|||||||
nftData.name,
|
nftData.name,
|
||||||
nftData.symbol,
|
nftData.symbol,
|
||||||
nftData.templateIndex,
|
nftData.templateIndex,
|
||||||
addressZERO,
|
ZERO_ADDRESS,
|
||||||
addressZERO,
|
ZERO_ADDRESS,
|
||||||
nftData.tokenURI,
|
nftData.tokenURI,
|
||||||
nftData.transferable,
|
nftData.transferable,
|
||||||
nftData.owner
|
nftData.owner
|
||||||
@ -139,8 +139,8 @@ export class NftFactory {
|
|||||||
nftData.name,
|
nftData.name,
|
||||||
nftData.symbol,
|
nftData.symbol,
|
||||||
nftData.templateIndex,
|
nftData.templateIndex,
|
||||||
addressZERO,
|
ZERO_ADDRESS,
|
||||||
addressZERO,
|
ZERO_ADDRESS,
|
||||||
nftData.tokenURI,
|
nftData.tokenURI,
|
||||||
nftData.transferable,
|
nftData.transferable,
|
||||||
nftData.owner
|
nftData.owner
|
||||||
@ -278,7 +278,7 @@ export class NftFactory {
|
|||||||
if ((await this.getOwner()) !== address) {
|
if ((await this.getOwner()) !== address) {
|
||||||
throw new Error(`Caller is not Factory Owner`)
|
throw new Error(`Caller is not Factory Owner`)
|
||||||
}
|
}
|
||||||
if (templateAddress === addressZERO) {
|
if (templateAddress === ZERO_ADDRESS) {
|
||||||
throw new Error(`Template cannot be ZERO address`)
|
throw new Error(`Template cannot be ZERO address`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ export class NftFactory {
|
|||||||
if ((await this.getOwner()) !== address) {
|
if ((await this.getOwner()) !== address) {
|
||||||
throw new Error(`Caller is not Factory Owner`)
|
throw new Error(`Caller is not Factory Owner`)
|
||||||
}
|
}
|
||||||
if (templateAddress === addressZERO) {
|
if (templateAddress === ZERO_ADDRESS) {
|
||||||
throw new Error(`Template cannot be address ZERO`)
|
throw new Error(`Template cannot be address ZERO`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ import {
|
|||||||
configHelperNetworks,
|
configHelperNetworks,
|
||||||
setContractDefaults,
|
setContractDefaults,
|
||||||
amountToUnits,
|
amountToUnits,
|
||||||
unitsToAmount
|
unitsToAmount,
|
||||||
|
ZERO_ADDRESS
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
import { Config } from '../../models/index.js'
|
import { Config } from '../../models/index.js'
|
||||||
import { PriceAndFees } from '../..'
|
import { PriceAndFees } from '../..'
|
||||||
@ -164,7 +165,7 @@ export class FixedRateExchange {
|
|||||||
exchangeId: string,
|
exchangeId: string,
|
||||||
datatokenAmount: string,
|
datatokenAmount: string,
|
||||||
maxBaseTokenAmount: string,
|
maxBaseTokenAmount: string,
|
||||||
consumeMarketAddress: string = '0x0000000000000000000000000000000000000000',
|
consumeMarketAddress: string = ZERO_ADDRESS,
|
||||||
consumeMarketFee: string = '0'
|
consumeMarketFee: string = '0'
|
||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const exchange = await this.getExchange(exchangeId)
|
const exchange = await this.getExchange(exchangeId)
|
||||||
@ -260,7 +261,7 @@ export class FixedRateExchange {
|
|||||||
exchangeId: string,
|
exchangeId: string,
|
||||||
datatokenAmount: string,
|
datatokenAmount: string,
|
||||||
minBaseTokenAmount: string,
|
minBaseTokenAmount: string,
|
||||||
consumeMarketAddress: string = '0x0000000000000000000000000000000000000000',
|
consumeMarketAddress: string = ZERO_ADDRESS,
|
||||||
consumeMarketFee: string = '0'
|
consumeMarketFee: string = '0'
|
||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const exchange = await this.getExchange(exchangeId)
|
const exchange = await this.getExchange(exchangeId)
|
||||||
|
@ -10,7 +10,8 @@ import {
|
|||||||
getFairGasPrice,
|
getFairGasPrice,
|
||||||
setContractDefaults,
|
setContractDefaults,
|
||||||
configHelperNetworks,
|
configHelperNetworks,
|
||||||
getFreOrderParams
|
getFreOrderParams,
|
||||||
|
ZERO_ADDRESS
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import {
|
import {
|
||||||
ConsumeMarketFee,
|
ConsumeMarketFee,
|
||||||
@ -206,8 +207,7 @@ export class Datatoken {
|
|||||||
|
|
||||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||||
|
|
||||||
if (!fixedRateParams.allowedConsumer)
|
if (!fixedRateParams.allowedConsumer) fixedRateParams.allowedConsumer = ZERO_ADDRESS
|
||||||
fixedRateParams.allowedConsumer = '0x0000000000000000000000000000000000000000'
|
|
||||||
const withMint = fixedRateParams.withMint ? 1 : 0
|
const withMint = fixedRateParams.withMint ? 1 : 0
|
||||||
|
|
||||||
let estGas
|
let estGas
|
||||||
@ -257,8 +257,7 @@ export class Datatoken {
|
|||||||
if (!(await this.isERC20Deployer(dtAddress, address))) {
|
if (!(await this.isERC20Deployer(dtAddress, address))) {
|
||||||
throw new Error(`User is not ERC20 Deployer`)
|
throw new Error(`User is not ERC20 Deployer`)
|
||||||
}
|
}
|
||||||
if (!fixedRateParams.allowedConsumer)
|
if (!fixedRateParams.allowedConsumer) fixedRateParams.allowedConsumer = ZERO_ADDRESS
|
||||||
fixedRateParams.allowedConsumer = '0x0000000000000000000000000000000000000000'
|
|
||||||
|
|
||||||
const withMint = fixedRateParams.withMint ? 1 : 0
|
const withMint = fixedRateParams.withMint ? 1 : 0
|
||||||
|
|
||||||
@ -320,8 +319,7 @@ export class Datatoken {
|
|||||||
this.config
|
this.config
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!dispenserParams.allowedSwapper)
|
if (!dispenserParams.allowedSwapper) dispenserParams.allowedSwapper = ZERO_ADDRESS
|
||||||
dispenserParams.allowedSwapper = '0x0000000000000000000000000000000000000000'
|
|
||||||
|
|
||||||
if (!dispenserParams.withMint) dispenserParams.withMint = false
|
if (!dispenserParams.withMint) dispenserParams.withMint = false
|
||||||
|
|
||||||
@ -367,8 +365,7 @@ export class Datatoken {
|
|||||||
this.config
|
this.config
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!dispenserParams.allowedSwapper)
|
if (!dispenserParams.allowedSwapper) dispenserParams.allowedSwapper = ZERO_ADDRESS
|
||||||
dispenserParams.allowedSwapper = '0x0000000000000000000000000000000000000000'
|
|
||||||
|
|
||||||
if (!dispenserParams.withMint) dispenserParams.withMint = false
|
if (!dispenserParams.withMint) dispenserParams.withMint = false
|
||||||
|
|
||||||
@ -975,8 +972,8 @@ export class Datatoken {
|
|||||||
)
|
)
|
||||||
if (!consumeMarketFee) {
|
if (!consumeMarketFee) {
|
||||||
consumeMarketFee = {
|
consumeMarketFee = {
|
||||||
consumeMarketFeeAddress: '0x0000000000000000000000000000000000000000',
|
consumeMarketFeeAddress: ZERO_ADDRESS,
|
||||||
consumeMarketFeeToken: '0x0000000000000000000000000000000000000000',
|
consumeMarketFeeToken: ZERO_ADDRESS,
|
||||||
consumeMarketFeeAmount: '0'
|
consumeMarketFeeAmount: '0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
import { Config } from '../models'
|
import { Config } from '../models'
|
||||||
import { minAbi } from './minAbi'
|
import { minAbi } from './minAbi'
|
||||||
import LoggerInstance from './Logger'
|
import LoggerInstance from './Logger'
|
||||||
|
import { ZERO_ADDRESS } from './Constants'
|
||||||
|
|
||||||
export function setContractDefaults(contract: Contract, config: Config): Contract {
|
export function setContractDefaults(contract: Contract, config: Config): Contract {
|
||||||
if (config) {
|
if (config) {
|
||||||
@ -65,8 +66,7 @@ export function getFreOrderParams(freParams: FreOrderParams): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getFreCreationParams(freParams: FreCreationParams): any {
|
export function getFreCreationParams(freParams: FreCreationParams): any {
|
||||||
if (!freParams.allowedConsumer)
|
if (!freParams.allowedConsumer) freParams.allowedConsumer = ZERO_ADDRESS
|
||||||
freParams.allowedConsumer = '0x0000000000000000000000000000000000000000'
|
|
||||||
const withMint = freParams.withMint ? 1 : 0
|
const withMint = freParams.withMint ? 1 : 0
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user