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

Represent unlimited ICS20 authorization amount as MaxInt256 #3452

Closed
3 tasks
Vvaradinov opened this issue Apr 13, 2023 · 0 comments · Fixed by #3454
Closed
3 tasks

Represent unlimited ICS20 authorization amount as MaxInt256 #3452

Vvaradinov opened this issue Apr 13, 2023 · 0 comments · Fixed by #3454
Labels
20-transfer type: refactor Architecture, code or CI improvements that may or may not tackle technical debt.

Comments

@Vvaradinov
Copy link
Contributor

Vvaradinov commented Apr 13, 2023

Summary

ICS20 authz spending limit always subtracts even if the value represents the maximum amount.

Problem Definition

The new ICS20 authorization included in v7 takes in a spending limit as a list of sdk.Coin and type int64. At Evmos we use ERC20 token allowance approvals that support an unlimited amount (which are represented as the max uint256 value). If we pass in the max uint256 amount effectively making it unlimited to the ICS20 authorization we assume that the amount will not be subtracted on each transfer.

Proposal

We propose the unlimited value be represented as the MaxUint256. This will require an additional check and skip substracting from the SpendLimit if the amount is MaxUint256.

var MaxUint256 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1))
if allocation.SpendLimit.AmountOf(msgTransfer.Token.Denom).Equal(sdk.NewIntFromBigInt(MaxUint256)) {
	return authz.AcceptResponse{Accept: true, Delete: false, Updated: &a}, nil
}

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
@crodriguezvega crodriguezvega added 20-transfer type: feature New features, sub-features or integrations type: refactor Architecture, code or CI improvements that may or may not tackle technical debt. and removed type: feature New features, sub-features or integrations labels Apr 14, 2023
@Vvaradinov Vvaradinov changed the title Represent unlimited ICS20 authorization amount as nil Represent unlimited ICS20 authorization amount as MaxInt64 Apr 25, 2023
@Vvaradinov Vvaradinov changed the title Represent unlimited ICS20 authorization amount as MaxInt64 Represent unlimited ICS20 authorization amount as MaxInt256 May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
20-transfer type: refactor Architecture, code or CI improvements that may or may not tackle technical debt.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants