Skip to content

Commit

Permalink
Merge pull request #3237 from jorgemmsilva/fix/decimals-migration-nil…
Browse files Browse the repository at this point in the history
…-uint64

fix: decimals migration - skip accounts with no base tokens
  • Loading branch information
jorgemmsilva authored Jan 23, 2024
2 parents 402b230 + 2a9e496 commit 4fdddd9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vm/core/migrations/m001/decimals_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ var AccountDecimals = migrations.Migration{
migrateBaseTokens := func(accKey []byte) {
// converts an account base token balance from uint64 to big.Int (while changing the decimals from 6 to 18)
key := accounts.BaseTokensKey(kv.Key(accKey))
amount := codec.MustDecodeUint64(state.Get(key))
amountBytes := state.Get(key)
if amountBytes == nil {
return
}
amount := codec.MustDecodeUint64(amountBytes)
amountMigrated := util.MustBaseTokensDecimalsToEthereumDecimalsExact(amount, 6)
state.Set(key, codec.EncodeBigIntAbs(amountMigrated))
}
Expand Down

0 comments on commit 4fdddd9

Please sign in to comment.