Skip to content

Commit

Permalink
log tx
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Mar 27, 2024
1 parent e00d68d commit 8897f38
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/modes/crouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,15 @@ const crouterClear = async(
">>> Transaction submitted successfully to the network, waiting for transaction to mine...",
"\n"
);

console.log(tx);
const receipt = config.timeout
? await promiseTimeout(
tx.wait(),
config.timeout,
`Transaction failed to mine after ${config.timeout}ms`
)
: await tx.wait();
console.log(receipt);
const income = getIncome(signer, receipt);
const clearActualPrice = getActualPrice(
receipt,
Expand Down
3 changes: 2 additions & 1 deletion src/modes/curve.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,15 @@ const curveClear = async(
">>> Transaction submitted successfully to the network, waiting for transaction to mine...",
"\n"
);

console.log(tx);
const receipt = config.timeout
? await promiseTimeout(
tx.wait(),
config.timeout,
`Transaction failed to mine after ${config.timeout}ms`
)
: await tx.wait();
console.log(receipt);
const income = getIncome(signer, receipt);
const clearActualPrice = getActualPrice(
receipt,
Expand Down
2 changes: 2 additions & 0 deletions src/modes/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,15 @@ const routerClear = async(
">>> Transaction submitted successfully to the network, waiting for transaction to mine...",
"\n"
);
console.log(tx);
const receipt = config.timeout
? await promiseTimeout(
tx.wait(),
config.timeout,
`Transaction failed to mine after ${config.timeout}ms`
)
: await tx.wait();
console.log(receipt);
const income = getIncome(signer, receipt);
const clearActualPrice = getActualPrice(
receipt,
Expand Down
2 changes: 2 additions & 0 deletions src/modes/srouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,15 @@ const srouterClear = async(
">>> Transaction submitted successfully to the network, waiting for transaction to mine...",
"\n"
);
console.log(tx);
const receipt = config.timeout
? await promiseTimeout(
tx.wait(),
config.timeout,
`Transaction failed to mine after ${config.timeout}ms`
)
: await tx.wait();
console.log(receipt);
if (receipt.status === 1) {
const clearActualAmount = getActualClearAmount(
arbAddress,
Expand Down
2 changes: 2 additions & 0 deletions src/modes/suniv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ const suniv2Clear = async(
">>> Transaction submitted successfully to the network, waiting for transaction to mine...",
"\n"
);
console.log(tx);
const receipt = config.timeout
? await promiseTimeout(
tx.wait(),
config.timeout,
`Transaction failed to mine after ${config.timeout}ms`
)
: await tx.wait();
console.log(receipt);
if (receipt.status === 1) {
const clearActualAmount = getActualClearAmount(
arbAddress,
Expand Down
2 changes: 2 additions & 0 deletions src/modes/zeroex.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,15 @@ const zeroExClear = async(
">>> Transaction submitted successfully to the network, waiting for transaction to mine...",
"\n"
);
console.log(tx);
const receipt = config.timeout
? await promiseTimeout(
tx.wait(),
config.timeout,
`Transaction failed to mine after ${config.timeout}ms`
)
: await tx.wait();
console.log(receipt);
const income = getIncome(signer, receipt);
const clearActualPrice = getActualPrice(
receipt,
Expand Down
46 changes: 23 additions & 23 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ const getOrderDetailsFromJson = async(jsonContent, signer) => {
* @param {...any} data - The optinnal data to hide
*/
const appGlobalLogger = (scrub, ...data) => {
const largeDataPattern = /0x[a-fA-F0-9]{128,}/g;
// const largeDataPattern = /0x[a-fA-F0-9]{128,}/g;
const consoleMethods = ["log", "warn", "error", "info", "debug"];

// Stringifies an object
Expand Down Expand Up @@ -1284,7 +1284,7 @@ const appGlobalLogger = (scrub, ...data) => {
const orgConsole = console[methodName];
console[methodName] = function (...params) {
const modifiedParams = [];
const shortenedLogs = [];
// const shortenedLogs = [];
for (let i = 0; i < params.length; i++) {
let logItem = params[i];
if (
Expand All @@ -1301,33 +1301,33 @@ const appGlobalLogger = (scrub, ...data) => {
"**********"
);
}
logItem = logItem.replace(
largeDataPattern,
largeData => {
if (!shortenedLogs.includes(largeData)) {
shortenedLogs.push(largeData);
return largeData;
}
else return largeData.slice(0, 67) + "...";
}
);
// logItem = logItem.replace(
// largeDataPattern,
// largeData => {
// if (!shortenedLogs.includes(largeData)) {
// shortenedLogs.push(largeData);
// return largeData;
// }
// else return largeData.slice(0, 67) + "...";
// }
// );
}
else if (typeof logItem === "object" && logItem !== null) {
logItem = objStringify(logItem);
if (scrub) for (let j = 0; j < _data.length; j++) {
logItem = objStrReplacer(logItem, _data[j], "**********");
}
logItem = objStrReplacer(
logItem,
largeDataPattern,
largeData => {
if (!shortenedLogs.includes(largeData)) {
shortenedLogs.push(largeData);
return largeData;
}
else return largeData.slice(0, 67) + "...";
}
);
// logItem = objStrReplacer(
// logItem,
// largeDataPattern,
// largeData => {
// if (!shortenedLogs.includes(largeData)) {
// shortenedLogs.push(largeData);
// return largeData;
// }
// else return largeData.slice(0, 67) + "...";
// }
// );
}
modifiedParams.push(logItem);
}
Expand Down

0 comments on commit 8897f38

Please sign in to comment.