Skip to content

Commit

Permalink
fix fs use
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfazakas committed Oct 6, 2023
1 parent c3ba01c commit 735dc2f
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/config/ConfigHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// eslint-disable-next-line import/no-named-default
import { default as DefaultContractsAddresses } from '@oceanprotocol/contracts/addresses/address.json'
import fs from 'fs'
import { Config } from '.'
import { LoggerInstance } from '../utils'

Expand Down Expand Up @@ -180,8 +179,8 @@ export class ConfigHelper {
DFRewards,
DFStrategyV1,
veFeeEstimate,
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI }),
...(process.env.PROVIDER_URI && { providerUri: process.env.PROVIDER_URI })
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
}
} else {
// no custom addresses structure was passed, trying to load default
Expand Down Expand Up @@ -219,8 +218,8 @@ export class ConfigHelper {
DFRewards,
DFStrategyV1,
veFeeEstimate,
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI }),
...(process.env.PROVIDER_URI && { providerUri: process.env.PROVIDER_URI })
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
}
}
}
Expand All @@ -241,16 +240,14 @@ export class ConfigHelper {
LoggerInstance.error(`No config found for given network '${network}'`)
return null
}
const customAddresses = process.env.ADDRESS_FILE
? JSON.parse(
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.readFileSync(process.env.ADDRESS_FILE, 'utf8')
)
: null
const contractAddressesConfig = this.getAddressesFromEnv(
config.network,
customAddresses
)

let addresses
try {
addresses = JSON.parse(process.env.ADDRESS_FILE)
} catch (e) {
addresses = null
}
const contractAddressesConfig = this.getAddressesFromEnv(config.network, addresses)
config = { ...config, ...contractAddressesConfig }

const nodeUri = infuraProjectId
Expand Down

0 comments on commit 735dc2f

Please sign in to comment.