From 53c8291ed517e5438c2f0e9e6da93f4236fd959a Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Thu, 20 Oct 2022 04:57:28 -0400 Subject: [PATCH] Use new makeError method in Contract. --- src.ts/contract/contract.ts | 8 ++++---- src.ts/contract/types.ts | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src.ts/contract/contract.ts b/src.ts/contract/contract.ts index d07e68f1c..9e985b561 100644 --- a/src.ts/contract/contract.ts +++ b/src.ts/contract/contract.ts @@ -143,7 +143,7 @@ export async function copyOverrides(arg: any): Promise>overrides; } export async function resolveArgs(_runner: null | ContractRunner, inputs: ReadonlyArray, args: Array): Promise> { @@ -253,19 +253,19 @@ class WrappedMethod = Array, R = any, D extends R | Co }); } - const fragment = this.getFragment(...args); const tx = await this.populateTransaction(...args); let result = "0x"; try { result = await runner.call(tx); } catch (error: any) { - if (isCallException(error)) { - throw this._contract.interface.makeError(fragment, error.data, tx); + if (isCallException(error) && error.data) { + throw this._contract.interface.makeError(error.data, tx); } throw error; } + const fragment = this.getFragment(...args); return this._contract.interface.decodeFunctionResult(fragment, result); } } diff --git a/src.ts/contract/types.ts b/src.ts/contract/types.ts index f6b132a42..81a01e4a5 100644 --- a/src.ts/contract/types.ts +++ b/src.ts/contract/types.ts @@ -24,6 +24,9 @@ export interface ContractTransaction extends PreparedTransactionRequest { // These are populated by contract methods and cannot bu null to: string; data: string; + + // These are resolved + from?: string; } // Deployment Transactions have no `to`