From 4f7b891da437ac876f92482b84935f3c80c7a339 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Mon, 4 Sep 2023 11:05:04 +0000 Subject: [PATCH] fix: support x/collection migration on old chains (#1106) * Support old chains * Update CHANGELOG.md * Add comment --- CHANGELOG.md | 1 + x/collection/keeper/migrations/v2/store.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc28f74e9..653f972260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/x/collection/keeper/migrations/v2/store.go b/x/collection/keeper/migrations/v2/store.go index 2ed0bb456b..d045c12290 100644 --- a/x/collection/keeper/migrations/v2/store.go +++ b/x/collection/keeper/migrations/v2/store.go @@ -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 @@ -104,6 +106,7 @@ func updateContractFTStatistics(store storetypes.KVStore, contractID string, sup } store.Set(supplyKey, bz) } else { + supply = sdk.ZeroInt() store.Delete(supplyKey) }