Fixed replacement transaction detection for JsonRpcSigner (#1658).
This commit is contained in:
parent
376cf3cdbf
commit
ee82e86ccc
@ -207,18 +207,26 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse> {
|
async sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse> {
|
||||||
return this.sendUncheckedTransaction(transaction).then((hash) => {
|
// This cannot be mined any earlier than any recent block
|
||||||
return poll(() => {
|
const blockNumber = await this.provider._getInternalBlockNumber(100 + 2 * this.provider.pollingInterval);
|
||||||
return this.provider.getTransaction(hash).then((tx: TransactionResponse) => {
|
|
||||||
|
// Send the transaction
|
||||||
|
const hash = await this.sendUncheckedTransaction(transaction);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Unfortunately, JSON-RPC only provides and opaque transaction hash
|
||||||
|
// for a response, and we need the actual transaction, so we poll
|
||||||
|
// for it; it should show up very quickly
|
||||||
|
return await poll(async () => {
|
||||||
|
const tx = await this.provider.getTransaction(hash);
|
||||||
if (tx === null) { return undefined; }
|
if (tx === null) { return undefined; }
|
||||||
return this.provider._wrapTransaction(tx, hash);
|
return this.provider._wrapTransaction(tx, hash, blockNumber);
|
||||||
});
|
}, { oncePoll: this.provider });
|
||||||
}, { oncePoll: this.provider }).catch((error: Error) => {
|
} catch (error) {
|
||||||
(<any>error).transactionHash = hash;
|
(<any>error).transactionHash = hash;
|
||||||
throw error;
|
throw error;
|
||||||
});
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async signMessage(message: Bytes | string): Promise<string> {
|
async signMessage(message: Bytes | string): Promise<string> {
|
||||||
|
Loading…
Reference in New Issue
Block a user