Skip to content

Commit

Permalink
Make executeContractFunction and callContractFunction logs more reada…
Browse files Browse the repository at this point in the history
…ble by logging argName=argValue
  • Loading branch information
Mihajlo-Pavlovic committed Nov 8, 2023
1 parent cf2ee30 commit 0a2c679
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/modules/blockchain/implementation/web3-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,17 @@ class Web3Service {
result = await contractInstance[functionName](...args);
} catch (error) {
const decodedErrorData = this._decodeErrorData(error, contractInstance.interface);

const functionFragment = contractInstance.interface.getFunction(
error.transaction.data.slice(0, 10),
);
const inputs = functionFragment.inputs.map(
(input, i) => `${input.name}=${args[i]}`,
);

// eslint-disable-next-line no-await-in-loop
await this.handleError(
Error(`Call ${functionName}(${args}) failed, reason: ${decodedErrorData}`),
Error(`Call ${functionName}(${inputs}) failed, reason: ${decodedErrorData}`),
);
}
}
Expand All @@ -424,9 +432,17 @@ class Web3Service {
gasLimit = await contractInstance.estimateGas[functionName](...args);
} catch (error) {
const decodedErrorData = this._decodeErrorData(error, contractInstance.interface);

const functionFragment = contractInstance.interface.getFunction(
error.transaction.data.slice(0, 10),
);
const inputs = functionFragment.inputs.map(
(input, i) => `${input.name}=${args[i]}`,
);

await this.handleError(
Error(
`Gas estimation ${functionName}(${args}) failed, reason: ${decodedErrorData}`,
`Gas estimation ${functionName}(${inputs}) failed, reason: ${decodedErrorData}`,
),
);
}
Expand Down

0 comments on commit 0a2c679

Please sign in to comment.