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)
}
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 networkId = await this.ocean.keeper.getNetworkId()
try {

View File

@ -53,7 +53,10 @@ export abstract class ContractBase extends Instantiable {
protected async init(config: InstantiableConfig) {
this.setInstanceConfig(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> {

View File

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