From 98bb58964bec7dff0ccf481d474354ec1ca6f376 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Wed, 3 Jun 2020 03:33:28 -0400 Subject: [PATCH] Allow undefined properties in transaction object and fix stray this (#860). --- packages/contracts/src.ts/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/contracts/src.ts/index.ts b/packages/contracts/src.ts/index.ts index 3619dc8474..23eba23347 100644 --- a/packages/contracts/src.ts/index.ts +++ b/packages/contracts/src.ts/index.ts @@ -231,7 +231,7 @@ async function populateTransaction(contract: Contract, fragment: FunctionFragmen // Make sure there are no stray overrides, which may indicate a // typo or using an unsupported key. - const leftovers = Object.keys(overrides); + const leftovers = Object.keys(overrides).filter((key) => ((overrides)[key] != null)); if (leftovers.length) { logger.throwError(`cannot override ${ leftovers.map((l) => JSON.stringify(l)).join(",") }`, Logger.errors.UNSUPPORTED_OPERATION, { operation: "overrides", @@ -271,10 +271,10 @@ function buildCall(contract: Contract, fragment: FunctionFragment, collapseSimpl let blockTag = undefined; if (args.length === fragment.inputs.length + 1 && typeof(args[args.length - 1]) === "object") { const overrides = shallowCopy(args.pop()); - if (overrides.blockTag) { + if (overrides.blockTag != null) { blockTag = await overrides.blockTag; - delete overrides.blockTag; } + delete overrides.blockTag; args.push(overrides); } @@ -337,7 +337,7 @@ function buildSend(contract: Contract, fragment: FunctionFragment): ContractFunc if (parsed) { event.args = parsed.args; event.decode = (data: BytesLike, topics?: Array) => { - return this.interface.decodeEventLog(parsed.eventFragment, data, topics); + return contract.interface.decodeEventLog(parsed.eventFragment, data, topics); }; event.event = parsed.name; event.eventSignature = parsed.signature;