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

Use SpendableCoins Interface instead of GetBalance #1562

Open
Hellobloc opened this issue Nov 27, 2024 · 3 comments
Open

Use SpendableCoins Interface instead of GetBalance #1562

Hellobloc opened this issue Nov 27, 2024 · 3 comments

Comments

@Hellobloc
Copy link

Hellobloc commented Nov 27, 2024

availableTokens := k.BK.GetBalance(ctx, claimer, plan.TotalAllocation.Denom)
if availableTokens.IsZero() {
return types.ErrNoTokensToClaim
}
// Burn all the FUT tokens the user have
err := k.BK.SendCoinsFromAccountToModule(ctx, claimer, types.ModuleName, sdk.NewCoins(availableTokens))
if err != nil {
return err
}

In the Claim method the user can burn FU tokens, this is done based on SendCoinsFromAccountToModule, which can be risky, specifically because the program supports the vestingAccount feature in GenesisAccount, which means that the balance returned by the GetBalance method may not always be spendable.

The vesting accounts may also contain Locked Coins, making it impossible to execute the claim method normally.

To avoid the potential risks that may exist, it is may more appropriate to use SpendableCoins.

@mtsitrin
Copy link
Contributor

mtsitrin commented Dec 4, 2024

Hi @Hellobloc
can u elabroate on the potential risk u see?

The IRO/ tokens minted by the x/iro module only
The tokens distributes in the GenesisAccount are already of the settled denom (IBC/12345678ABCD)

not sure there's a scenario where the IRO/ tokens are locked for vesting
and even if they do, the claim will fail as expected

@Hellobloc
Copy link
Author

Hellobloc commented Dec 4, 2024

Thank you very much for your reply.

Sorry for the lack info in this issue, I initially thought that the claim of RA token would not allowed be affected by vesting account. This means that even in a vesting account, the FU Tokens could still be burned to complete the RA Token claim. However, it seems that vesting accounts might prevent the RA Token claim, even these vesting account just want to burn the token which is not been lock in vesting. This means that a vesting account can not perform FU token burn operation unless he doesn't have any lock tokens

On the other hand, I thought that replacing the GetBalance operation with SpendableCoins would allow vesting accounts to execute the claim operation nomally. which means such a replacement would have a positive externality. So that's why i post this issue!

@mtsitrin
Copy link
Contributor

Hi @Hellobloc
The vesting accounts defined on GenesisAccounts is on the Rollapp state
The IRO tokens claims are on the Hub

not sure how it's relates
also, the IRO/ token is not vesting anywhere

If u can share reproduction steps it will be very helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants