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

refactor: balance initialization #252

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hitwill
Copy link

@hitwill hitwill commented May 25, 2024

re-use code to reduce probability of mistakes

re-use code to reduce probability of mistakes
@twilson63
Copy link
Collaborator

What if you don't want your total supply awarded to the process balance? what if you want to enable a mint process?

@hitwill
Copy link
Author

hitwill commented Jun 4, 2024

What if you don't want your total supply awarded to the process balance?

A good point. But I think it would be the same with the current code:

Balances = Balances or { [ao.id] = utils.toBalanceValue(10000 * 10 ^ Denomination) }
TotalSupply = TotalSupply or utils.toBalanceValue(10000 * 10 ^ Denomination)

Or with the proposed change

TotalSupply = TotalSupply or utils.toBalanceValue(10000 * 10 ^ Denomination)
Balances = Balances or { [ao.id] = TotalSupply }

Where the coder needs to update balances to

Balances = Balances or {}

The proposed change is tiny, but I feel it keeps the code DRY and reduces that small chance of an error

@twilson63 twilson63 added the hold label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants