Skip to content

Commit

Permalink
Fixes Erroneous Approval Error (#1125)
Browse files Browse the repository at this point in the history
## Motivation

We were erroneously blocking you from calling `approve()` with too low
of a balance. This doesn't reflect how things work on chain.

## Solution

Remove that check
  • Loading branch information
kalverra authored Jul 1, 2024
1 parent ac01f93 commit c0b080a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 2 additions & 1 deletion integration-tests/ccip-tests/actions/ccip_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ func (ccipModule *CCIPCommon) ApproveTokens() error {
return fmt.Errorf("failed to get allowance for token %s: %w", token.ContractAddress.Hex(), err)
}
if allowance.Cmp(ApprovedAmountToRouter) < 0 {
err := token.Approve(ccipModule.ChainClient.GetDefaultWallet(), ccipModule.Router.Address(), ApprovedAmountToRouter)
allowanceApprovalDelta := new(big.Int).Sub(ApprovedAmountToRouter, allowance)
err := token.Approve(ccipModule.ChainClient.GetDefaultWallet(), ccipModule.Router.Address(), allowanceApprovalDelta)
if err != nil {
return fmt.Errorf("failed to approve token %s: %w", token.ContractAddress.Hex(), err)
}
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/ccip-tests/contracts/contract_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,6 @@ func (token *ERC20Token) Approve(onBehalf *blockchain.EthereumWallet, spender st
if err != nil {
return fmt.Errorf("failed to get balance of onBehalf: %w", err)
}
if onBehalfBalance.Cmp(amount) < 0 {
return fmt.Errorf("onBehalf '%s' does not have enough balance to approve", onBehalf.Address())
}
currentAllowance, err := token.Allowance(onBehalf.Address(), spender)
if err != nil {
return fmt.Errorf("failed to get current allowance for '%s' on behalf of '%s': %w", spender, onBehalf.Address(), err)
Expand Down

0 comments on commit c0b080a

Please sign in to comment.