@@ -6,6 +6,7 @@ package keeper
66
77import (
88 "fmt"
9+ "strings"
910
1011 "github.com/crypto-org-chain/chain-main/v8/x/nft/types"
1112
@@ -28,7 +29,7 @@ func AllInvariants(k Keeper) sdk.Invariant {
2829func SupplyInvariant (k Keeper ) sdk.Invariant {
2930 return func (ctx sdk.Context ) (string , bool ) {
3031 ownersCollectionsSupply := make (map [string ]uint64 )
31- var msg string
32+ var msg strings. Builder
3233 count := 0
3334
3435 owners , err := k .GetOwners (ctx )
@@ -45,19 +46,19 @@ func SupplyInvariant(k Keeper) sdk.Invariant {
4546 for denom , supply := range ownersCollectionsSupply {
4647 if supply != k .GetTotalSupply (ctx , denom ) {
4748 count ++
48- msg += fmt .Sprintf (
49+ msg . WriteString ( fmt .Sprintf (
4950 "total %s NFTs supply invariance:\n " +
5051 "\t total %s NFTs supply: %d\n " +
5152 "\t sum of %s NFTs by owner: %d\n " ,
5253 denom , denom , supply , denom , ownersCollectionsSupply [denom ],
53- )
54+ ))
5455 }
5556 }
5657 broken := count != 0
5758
5859 return sdk .FormatInvariant (
5960 types .ModuleName , "supply" ,
60- fmt .Sprintf ("%d NFT supply invariants found\n %s" , count , msg ),
61+ fmt .Sprintf ("%d NFT supply invariants found\n %s" , count , msg . String () ),
6162 ), broken
6263 }
6364}
0 commit comments