Skip to content

Commit

Permalink
Major Contract refactor for overrides (ethers-io#819, ethers-io#845, e…
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jun 1, 2020
1 parent 1261953 commit 0018446
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src.ts/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -678,7 +678,7 @@ export class BaseProvider extends Provider {
}
}

async _getTransactionRequest(transaction: TransactionRequest | Promise<TransactionRequest>): Promise<Transaction> {
async _getTransactionRequest(transaction: Deferrable<TransactionRequest>): Promise<Transaction> {
const values: any = await transaction;

const tx: any = { };
Expand Down Expand Up @@ -723,8 +723,7 @@ export class BaseProvider extends Provider {
return this.formatter.filter(await resolveProperties(result));
}


async call(transaction: TransactionRequest | Promise<TransactionRequest>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string> {
async call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string> {
await this.ready;
const params = await resolveProperties({
transaction: this._getTransactionRequest(transaction),
Expand All @@ -733,7 +732,7 @@ export class BaseProvider extends Provider {
return hexlify(await this.perform("call", params));
}

async estimateGas(transaction: TransactionRequest | Promise<TransactionRequest>): Promise<BigNumber> {
async estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber> {
await this.ready;
const params = await resolveProperties({
transaction: this._getTransactionRequest(transaction)
Expand Down
10 changes: 5 additions & 5 deletions src.ts/json-rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -99,7 +99,7 @@ export class JsonRpcSigner extends Signer {
});
}

sendUncheckedTransaction(transaction: TransactionRequest): Promise<string> {
sendUncheckedTransaction(transaction: Deferrable<TransactionRequest>): Promise<string> {
transaction = shallowCopy(transaction);

let fromAddress = this.getAddress().then((address) => {
Expand Down Expand Up @@ -149,13 +149,13 @@ export class JsonRpcSigner extends Signer {
});
}

signTransaction(transaction: TransactionRequest): Promise<string> {
signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string> {
return logger.throwError("signing transactions is unsupported", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "signTransaction"
});
}

sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse> {
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse> {
return this.sendUncheckedTransaction(transaction).then((hash) => {
return poll(() => {
return this.provider.getTransaction(hash).then((tx: TransactionResponse) => {
Expand Down Expand Up @@ -188,7 +188,7 @@ export class JsonRpcSigner extends Signer {
}

class UncheckedJsonRpcSigner extends JsonRpcSigner {
sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse> {
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse> {
return this.sendUncheckedTransaction(transaction).then((hash) => {
return <TransactionResponse>{
hash: hash,
Expand Down

0 comments on commit 0018446

Please sign in to comment.