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

Fixes Erroneous Approval Error #1125

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
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
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)
AnieeG marked this conversation as resolved.
Show resolved Hide resolved
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
Loading