diff --git a/packages/providers/src.ts/json-rpc-provider.ts b/packages/providers/src.ts/json-rpc-provider.ts index cb374a1a8..4de75f8af 100644 --- a/packages/providers/src.ts/json-rpc-provider.ts +++ b/packages/providers/src.ts/json-rpc-provider.ts @@ -207,18 +207,22 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner { }); } - sendTransaction(transaction: Deferrable): Promise { - return this.sendUncheckedTransaction(transaction).then((hash) => { - return poll(() => { - return this.provider.getTransaction(hash).then((tx: TransactionResponse) => { - if (tx === null) { return undefined; } - return this.provider._wrapTransaction(tx, hash); - }); - }, { oncePoll: this.provider }).catch((error: Error) => { - (error).transactionHash = hash; - throw error; - }); - }); + async sendTransaction(transaction: Deferrable): Promise { + const hash = await this.sendUncheckedTransaction(transaction) + + try { + return poll(async () => { + const tx : TransactionResponse = await this.provider.getTransaction(hash) + if (tx === null) { return undefined; } + + const startBlock = await this.provider._getInternalBlockNumber(100 + 2 * this.provider.pollingInterval) + + return this.provider._wrapTransaction(tx, hash, startBlock); + }, { oncePoll: this.provider }) + } catch(error) { + (error).transactionHash = hash; + throw error; + } } async signMessage(message: Bytes | string): Promise {