Skip to content

Commit

Permalink
fix: use the feesReceiver to estimate native payment (#94)
Browse files Browse the repository at this point in the history
* fix: use the feesReceiver to estimate native payment

* build: update version
  • Loading branch information
antomor authored Jul 31, 2024
1 parent f675abd commit a856fdd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rsksmart/rif-relay-client",
"version": "2.2.2",
"version": "2.2.3",
"private": false,
"description": "This project contains all the client code for the rif relay system.",
"license": "MIT",
Expand Down
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ const estimatePaymentGas = async ({
const isNativePayment = (await tokenContract) === constants.AddressZero;

if (isNativePayment) {
// Ideally we should set `from` with the tokenOrigin address,
// but the tokenOrigin may not have funds, hence the estimation will fail
// so we set the feesReceiver as the `from` address.
// This may be wrong in case the feesReceiver performs some operations using
// the msg.sender address in the fallback/receive function.
return await estimateInternalCallGas({
from: tokenOrigin,
from: feesReceiver,
to: feesReceiver,
gasPrice,
value: tokenAmount,
Expand Down

0 comments on commit a856fdd

Please sign in to comment.