Skip to content

Commit

Permalink
fix: support x/collection migration on old chains (#1106)
Browse files Browse the repository at this point in the history
* Support old chains

* Update CHANGELOG.md

* Add comment
  • Loading branch information
0Tech authored Sep 4, 2023
1 parent 0a27aef commit 4f7b891
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (ostracon) [\#1099](https://github.com/Finschia/finschia-sdk/pull/1099) feat!: remove libsodium vrf library.
* (x/collection) [\#1102](https://github.com/finschia/finschia-sdk/pull/1102) Reject modifying NFT class with token index filled in MsgModify
* (x/collection) [\#1105](https://github.com/Finschia/finschia-sdk/pull/1105) Add minted coins to balance in x/collection MsgMintFT
* (x/collection) [\#1106](https://github.com/Finschia/finschia-sdk/pull/1106) Support x/collection migration on old chains

### Build, CI
* (build,ci) [\#1043](https://github.com/Finschia/finschia-sdk/pull/1043) Update golang version to 1.20
Expand Down
5 changes: 4 additions & 1 deletion x/collection/keeper/migrations/v2/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ func updateContractFTStatistics(store storetypes.KVStore, contractID string, sup
return err
}

for intClassID := uint64(1); intClassID < nextClassIDs.Fungible.Uint64(); intClassID++ {
// In the old chains, classID of fungible tokens starts from zero
// In the new chains, it starts from one, but it does not hurts because amount of zero is not set to the store.
for intClassID := uint64(0); intClassID < nextClassIDs.Fungible.Uint64(); intClassID++ {
classID := fmt.Sprintf("%08x", intClassID)

// update supply
Expand All @@ -104,6 +106,7 @@ func updateContractFTStatistics(store storetypes.KVStore, contractID string, sup
}
store.Set(supplyKey, bz)
} else {
supply = sdk.ZeroInt()
store.Delete(supplyKey)
}

Expand Down

0 comments on commit 4f7b891

Please sign in to comment.