mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Feature/ Use custom addresses & fallback signature to legacy (#1772)
* add fixes * added logs * added missed fs call * debug ci * add more checks * fix custom addr check
This commit is contained in:
parent
fc0782be5c
commit
8f28f3b029
@ -1,5 +1,6 @@
|
|||||||
// eslint-disable-next-line import/no-named-default
|
// eslint-disable-next-line import/no-named-default
|
||||||
import { default as DefaultContractsAddresses } from '@oceanprotocol/contracts/addresses/address.json'
|
import { default as DefaultContractsAddresses } from '@oceanprotocol/contracts/addresses/address.json'
|
||||||
|
import fs from 'fs'
|
||||||
import { Config } from '.'
|
import { Config } from '.'
|
||||||
import { LoggerInstance } from '../utils'
|
import { LoggerInstance } from '../utils'
|
||||||
|
|
||||||
@ -144,9 +145,8 @@ export class ConfigHelper {
|
|||||||
public getAddressesFromEnv(network: string, customAddresses?: any): Partial<Config> {
|
public getAddressesFromEnv(network: string, customAddresses?: any): Partial<Config> {
|
||||||
// use the defaults first
|
// use the defaults first
|
||||||
let configAddresses: Partial<Config>
|
let configAddresses: Partial<Config>
|
||||||
|
|
||||||
// load from custom addresses structure
|
// load from custom addresses structure
|
||||||
if (customAddresses) {
|
if (customAddresses && customAddresses[network]) {
|
||||||
const {
|
const {
|
||||||
FixedPrice,
|
FixedPrice,
|
||||||
Dispenser,
|
Dispenser,
|
||||||
@ -180,7 +180,8 @@ export class ConfigHelper {
|
|||||||
DFRewards,
|
DFRewards,
|
||||||
DFStrategyV1,
|
DFStrategyV1,
|
||||||
veFeeEstimate,
|
veFeeEstimate,
|
||||||
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI })
|
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI }),
|
||||||
|
...(process.env.PROVIDER_URI && { providerUri: process.env.PROVIDER_URI })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no custom addresses structure was passed, trying to load default
|
// no custom addresses structure was passed, trying to load default
|
||||||
@ -218,7 +219,8 @@ export class ConfigHelper {
|
|||||||
DFRewards,
|
DFRewards,
|
||||||
DFStrategyV1,
|
DFStrategyV1,
|
||||||
veFeeEstimate,
|
veFeeEstimate,
|
||||||
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI })
|
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI }),
|
||||||
|
...(process.env.PROVIDER_URI && { providerUri: process.env.PROVIDER_URI })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,8 +241,16 @@ export class ConfigHelper {
|
|||||||
LoggerInstance.error(`No config found for given network '${network}'`)
|
LoggerInstance.error(`No config found for given network '${network}'`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
const customAddresses = process.env.ADDRESS_FILE
|
||||||
const contractAddressesConfig = this.getAddressesFromEnv(config.network)
|
? 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
|
||||||
|
)
|
||||||
config = { ...config, ...contractAddressesConfig }
|
config = { ...config, ...contractAddressesConfig }
|
||||||
|
|
||||||
const nodeUri = infuraProjectId
|
const nodeUri = infuraProjectId
|
||||||
|
@ -126,12 +126,16 @@ export class Provider {
|
|||||||
)
|
)
|
||||||
const messageHashBytes = ethers.utils.arrayify(consumerMessage)
|
const messageHashBytes = ethers.utils.arrayify(consumerMessage)
|
||||||
const chainId = await signer.getChainId()
|
const chainId = await signer.getChainId()
|
||||||
if (chainId === 8996) {
|
try {
|
||||||
return await (signer as providers.JsonRpcSigner)._legacySignMessage(
|
return await signer.signMessage(messageHashBytes)
|
||||||
messageHashBytes
|
} catch (error) {
|
||||||
)
|
LoggerInstance.error('Sign provider message error: ', error)
|
||||||
|
if (chainId === 8996) {
|
||||||
|
return await (signer as providers.JsonRpcSigner)._legacySignMessage(
|
||||||
|
messageHashBytes
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return await signer.signMessage(messageHashBytes)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user