Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend support of transaction replacement detection to JsonRPCProviders #1658

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions packages/providers/src.ts/json-rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,22 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
});
}

sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse> {
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) => {
(<any>error).transactionHash = hash;
throw error;
});
});
async sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse> {
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) {
(<any>error).transactionHash = hash;
throw error;
}
}

async signMessage(message: Bytes | string): Promise<string> {
Expand Down