Fix backwards compatibility with certain parsed JSON objects passed into Interface and Contracts (#721).

This commit is contained in:
Richard Moore 2020-01-29 22:01:42 -05:00
parent df51b26fe7
commit 0589b3102e
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
2 changed files with 9 additions and 3 deletions

@ -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 | FunctionFragment | EventFragment> | 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 | FunctionFragment | EventFragment | ParamType> | 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 | FunctionFragment | EventFragment> | 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 | FunctionFragment | EventFragment | ParamType> | string | Interface, bytecode: Arrayish | string | { object: string }, signer?: Signer) {
let bytecodeHex: string = null;

@ -390,7 +390,9 @@ export class Interface {
readonly events: { [ name: string ]: _EventDescription };
readonly deployFunction: _DeployDescription;
constructor(abi: Array<string | FunctionFragment | EventFragment> | string) {
// ParamType is not actually correct here, but for legacy reasons,
// we need it. See #721.
constructor(abi: Array<string | FunctionFragment | EventFragment | ParamType> | string) {
errors.checkNew(this, Interface);
if (typeof(abi) === 'string') {