1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Fix error on getting contract address of not loaded contracts.

This commit is contained in:
Pedro Gutiérrez 2019-06-25 12:27:00 +02:00
parent cb3717460b
commit 4c3f134942
3 changed files with 17 additions and 11 deletions

View File

@ -35,7 +35,10 @@ export default class ContractHandler extends Instantiable {
this.setInstanceConfig(config) this.setInstanceConfig(config)
} }
public async get(what: string, optional: boolean = false): Promise<Contract> { public async get(
what: string,
optional: boolean = false
): Promise<Contract> {
const where = (await this.ocean.keeper.getNetworkName()).toLowerCase() const where = (await this.ocean.keeper.getNetworkName()).toLowerCase()
const networkId = await this.ocean.keeper.getNetworkId() const networkId = await this.ocean.keeper.getNetworkId()
try { try {

View File

@ -53,7 +53,10 @@ export abstract class ContractBase extends Instantiable {
protected async init(config: InstantiableConfig) { protected async init(config: InstantiableConfig) {
this.setInstanceConfig(config) this.setInstanceConfig(config)
const contractHandler = new ContractHandler(config) const contractHandler = new ContractHandler(config)
this.contract = await contractHandler.get(this.contractName, this.optional) this.contract = await contractHandler.get(
this.contractName,
this.optional
)
} }
protected async getFromAddress(from?: string): Promise<string> { protected async getFromAddress(from?: string): Promise<string> {

View File

@ -62,9 +62,9 @@ export class OceanVersions extends Instantiable {
status: OceanPlatformTechStatus.Working, status: OceanPlatformTechStatus.Working,
network: (await this.ocean.keeper.getNetworkName()).toLowerCase(), network: (await this.ocean.keeper.getNetworkName()).toLowerCase(),
keeperVersion: keeperPackageJson.version, keeperVersion: keeperPackageJson.version,
contracts: Object.values( contracts: Object.values(await this.ocean.keeper.getAllInstances())
await this.ocean.keeper.getAllInstances() .filter(_ => !!_)
).reduce( .reduce(
(acc, { contractName, address }) => ({ (acc, { contractName, address }) => ({
...acc, ...acc,
[contractName]: address [contractName]: address