Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 39 - use call instead of try catch #79

Open
wants to merge 1 commit into
base: merge-train-r5
Choose a base branch
from
Open
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
47 changes: 44 additions & 3 deletions packages/contracts/contracts/TellerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -933,10 +933,11 @@ contract TellerV2 is

}

address loanRepaymentListener = repaymentListenerForBid[_bidId];
address loanRepaymentListener = repaymentListenerForBid[_bidId];

if (loanRepaymentListener != address(0)) {
require(gasleft() >= 80000, "NR gas"); //fixes the 63/64 remaining issue

/*require(gasleft() >= 80000, "NR gas"); //fixes the 63/64 remaining issue
try
ILoanRepaymentListener(loanRepaymentListener).repayLoanCallback{
gas: 80000
Expand All @@ -946,10 +947,50 @@ contract TellerV2 is
_payment.principal,
_payment.interest
)
{} catch {}
{} catch {} */

bool repayCallbackSucccess = safeRepayLoanCallback(
loanRepaymentListener,
_bidId,
_msgSenderForMarket(bid.marketplaceId),
_payment.principal,
_payment.interest
);


}
}


function safeRepayLoanCallback(
address _loanRepaymentListener,
uint256 _bidId,
address _sender,
uint256 _principal,
uint256 _interest
) internal virtual returns (bool) {


( bool callSuccess, bytes memory callReturnData ) = ExcessivelySafeCall.excessivelySafeCall(
address(_loanRepaymentListener),
80000, //max gas
0, //value (eth) to send in call
1000, //max return data size
abi.encodeWithSelector(
ILoanRepaymentListener
.repayLoanCallback
.selector,
_bidId,
_sender,
_principal,
_interest
)
);


return callSuccess ;
}

/*
A try/catch pattern for safeTransferERC20 that helps support standard ERC20 tokens and non-standard ones like USDT

Expand Down
Loading