Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Bug fix: Make receipts work properly with --stacktrace #3816

Merged
merged 3 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion packages/contract/lib/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ const execute = {
.sendTransaction(web3, params, promiEvent, context) //the crazy things we do for stacktracing...
.then(receipt => {
if (promiEvent.debug) {
promiEvent.resolve(receipt);
// in this case, we need to manually invoke the handler since it
// hasn't been set up (hack?)
handlers.receipt(context, receipt);
}
//otherwise, just let the handlers handle things
})
Expand Down
6 changes: 5 additions & 1 deletion packages/contract/lib/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ const handlers = {
logs: receipt.logs
});

this.removeListener("receipt", handlers.receipt);
//HACK: adding this conditional for when the handler is invoked
//manually during stacktracing
if (this.removeListener) {
this.removeListener("receipt", handlers.receipt);
}
}
};

Expand Down
4 changes: 3 additions & 1 deletion packages/contract/lib/manual-send.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const debug = require("debug")("contract:manual-send");
const ethers = require("ethers");
const Utils = require ("./utils");
const { formatters } = require("web3-core-helpers"); //used for reproducing web3's behavior

//this is less manual now, it uses ethers, whew
Expand Down Expand Up @@ -36,6 +37,7 @@ async function sendTransactionManual(web3, params, promiEvent) {
}
}
debug("txHash: %s", txHash);
receipt = translateReceipt(receipt);
promiEvent.setTransactionHash(txHash); //this here is why I wrote this function @_@
return await handleResult(receipt, transaction.to == null);
}
Expand Down Expand Up @@ -104,7 +106,7 @@ function setUpParameters(params, web3) {
function translateReceipt(receipt) {
return Object.assign({},
...Object.entries(receipt).map(([key, value]) => ({
[key]: ethers.BigNumber.isBigNumber(value)
[key]: Utils.is_big_number(value)
? value.toNumber()
: value
}))
Expand Down