From 0589b3102e2da702f4ac19a32c8b083faa6bbeea Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Wed, 29 Jan 2020 22:01:42 -0500 Subject: [PATCH] Fix backwards compatibility with certain parsed JSON objects passed into Interface and Contracts (#721). --- src.ts/contract.ts | 8 ++++++-- src.ts/utils/interface.ts | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src.ts/contract.ts b/src.ts/contract.ts index dc3583bdd..3e0d614aa 100644 --- a/src.ts/contract.ts +++ b/src.ts/contract.ts @@ -364,7 +364,9 @@ export class Contract { // Once this issue is resolved (there are open PR) we can do this nicer // by making addressOrName default to null for 2 operand calls. :) - constructor(addressOrName: string, contractInterface: Array | string | Interface, signerOrProvider: Signer | Provider) { + // ParamType is not actually correct here, but for legacy reasons, + // we need it. See #721. + constructor(addressOrName: string, contractInterface: Array | string | Interface, signerOrProvider: Signer | Provider) { errors.checkNew(this, Contract); // @TODO: Maybe still check the addressOrName looks like a valid address or name? @@ -744,7 +746,9 @@ export class ContractFactory { readonly bytecode: string; readonly signer: Signer; - constructor(contractInterface: Array | string | Interface, bytecode: Arrayish | string | { object: string }, signer?: Signer) { + // ParamType is not actually correct here, but for legacy reasons, + // we need it. See #721. + constructor(contractInterface: Array | string | Interface, bytecode: Arrayish | string | { object: string }, signer?: Signer) { let bytecodeHex: string = null; diff --git a/src.ts/utils/interface.ts b/src.ts/utils/interface.ts index 7b45a31f5..91b250498 100644 --- a/src.ts/utils/interface.ts +++ b/src.ts/utils/interface.ts @@ -390,7 +390,9 @@ export class Interface { readonly events: { [ name: string ]: _EventDescription }; readonly deployFunction: _DeployDescription; - constructor(abi: Array | string) { + // ParamType is not actually correct here, but for legacy reasons, + // we need it. See #721. + constructor(abi: Array | string) { errors.checkNew(this, Interface); if (typeof(abi) === 'string') {