From 001844639f26d06685558132cea5efc7078dcc7f Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 1 Jun 2020 04:46:37 -0400 Subject: [PATCH] Major Contract refactor for overrides (#819, #845, #847, #860). --- src.ts/base-provider.ts | 9 ++++----- src.ts/json-rpc-provider.ts | 10 +++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src.ts/base-provider.ts b/src.ts/base-provider.ts index 6c72b18131..a7db854bc8 100644 --- a/src.ts/base-provider.ts +++ b/src.ts/base-provider.ts @@ -8,7 +8,7 @@ import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; import { arrayify, hexDataLength, hexlify, hexValue, isHexString } from "@ethersproject/bytes"; import { namehash } from "@ethersproject/hash"; import { getNetwork, Network, Networkish } from "@ethersproject/networks"; -import { defineReadOnly, getStatic, resolveProperties } from "@ethersproject/properties"; +import { Deferrable, defineReadOnly, getStatic, resolveProperties } from "@ethersproject/properties"; import { Transaction } from "@ethersproject/transactions"; import { toUtf8String } from "@ethersproject/strings"; import { poll } from "@ethersproject/web"; @@ -678,7 +678,7 @@ export class BaseProvider extends Provider { } } - async _getTransactionRequest(transaction: TransactionRequest | Promise): Promise { + async _getTransactionRequest(transaction: Deferrable): Promise { const values: any = await transaction; const tx: any = { }; @@ -723,8 +723,7 @@ export class BaseProvider extends Provider { return this.formatter.filter(await resolveProperties(result)); } - - async call(transaction: TransactionRequest | Promise, blockTag?: BlockTag | Promise): Promise { + async call(transaction: Deferrable, blockTag?: BlockTag | Promise): Promise { await this.ready; const params = await resolveProperties({ transaction: this._getTransactionRequest(transaction), @@ -733,7 +732,7 @@ export class BaseProvider extends Provider { return hexlify(await this.perform("call", params)); } - async estimateGas(transaction: TransactionRequest | Promise): Promise { + async estimateGas(transaction: Deferrable): Promise { await this.ready; const params = await resolveProperties({ transaction: this._getTransactionRequest(transaction) diff --git a/src.ts/json-rpc-provider.ts b/src.ts/json-rpc-provider.ts index cee81148de..8b63827e45 100644 --- a/src.ts/json-rpc-provider.ts +++ b/src.ts/json-rpc-provider.ts @@ -7,7 +7,7 @@ import { Signer } from "@ethersproject/abstract-signer"; import { BigNumber } from "@ethersproject/bignumber"; import { Bytes, hexlify, hexValue } from "@ethersproject/bytes"; import { Network, Networkish } from "@ethersproject/networks"; -import { checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import { checkProperties, deepCopy, Deferrable, defineReadOnly, getStatic, resolveProperties, shallowCopy } from "@ethersproject/properties"; import { toUtf8Bytes } from "@ethersproject/strings"; import { ConnectionInfo, fetchJson, poll } from "@ethersproject/web"; @@ -99,7 +99,7 @@ export class JsonRpcSigner extends Signer { }); } - sendUncheckedTransaction(transaction: TransactionRequest): Promise { + sendUncheckedTransaction(transaction: Deferrable): Promise { transaction = shallowCopy(transaction); let fromAddress = this.getAddress().then((address) => { @@ -149,13 +149,13 @@ export class JsonRpcSigner extends Signer { }); } - signTransaction(transaction: TransactionRequest): Promise { + signTransaction(transaction: Deferrable): Promise { return logger.throwError("signing transactions is unsupported", Logger.errors.UNSUPPORTED_OPERATION, { operation: "signTransaction" }); } - sendTransaction(transaction: TransactionRequest): Promise { + sendTransaction(transaction: Deferrable): Promise { return this.sendUncheckedTransaction(transaction).then((hash) => { return poll(() => { return this.provider.getTransaction(hash).then((tx: TransactionResponse) => { @@ -188,7 +188,7 @@ export class JsonRpcSigner extends Signer { } class UncheckedJsonRpcSigner extends JsonRpcSigner { - sendTransaction(transaction: TransactionRequest): Promise { + sendTransaction(transaction: Deferrable): Promise { return this.sendUncheckedTransaction(transaction).then((hash) => { return { hash: hash,