mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-05-31 11:16:38 +00:00

* adjust issuePoPRewards to mint stagedCRDDL * add GetChallengeRange * add resolveStagedClaims on ReissueRDDLResult msg * move claim resolve to distribution result * add StagedDenom and ClaimDenom to config * added the prepare4linting.sh script * renamed PoPEpochs to PopEpochs * renamed DistributionAddressPoP to DistributionAddressPop * added config value ReIssuanceEpochs * detached the re-issuance from the distribution process and schedule them independently * changed logging messages * added an explicit util/kv_serialize.go file to have all KV serialization done * switched to Bigendian serialization of int64 to have the ordered list on the kvstore * added ComputeReIssuanceValue to enable re-issuances once a day or defined by ReIssuanceEpoch * integrated a ReIssuanceValue computation test case * adjusted the challenges test cases to be epoch-dependent * added ReIssuances per ReIssuanceEpoch * extended the Reissue message * checking ReIssuanceProposal in the ante handler * added precision setter for the UINT to RDDL token converter (and test cases) * add e2e test case for pop rewards Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package keeper
|
|
|
|
import (
|
|
"github.com/planetmint/planetmint-go/util"
|
|
"github.com/planetmint/planetmint-go/x/asset/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/store/prefix"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
func (k Keeper) StoreAsset(ctx sdk.Context, msg types.MsgNotarizeAsset) {
|
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AssetKey))
|
|
store.Set(util.SerializeString(msg.GetCid()), []byte(msg.GetCreator()))
|
|
}
|
|
|
|
func (k Keeper) GetAsset(ctx sdk.Context, cid string) (msg types.MsgNotarizeAsset, found bool) {
|
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AssetKey))
|
|
creatorBytes := store.Get(util.SerializeString(cid))
|
|
if creatorBytes == nil {
|
|
return msg, false
|
|
}
|
|
msg.Cid = cid
|
|
msg.Creator = string(creatorBytes)
|
|
return msg, true
|
|
}
|
|
|
|
func (k Keeper) GetCidsByAddress(ctx sdk.Context, address string) (cids []string, found bool) {
|
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AssetKey))
|
|
|
|
reverseIterator := store.ReverseIterator(nil, nil)
|
|
defer reverseIterator.Close()
|
|
for ; reverseIterator.Valid(); reverseIterator.Next() {
|
|
addressBytes := reverseIterator.Value()
|
|
cidBytes := reverseIterator.Key()
|
|
|
|
if string(addressBytes) == address {
|
|
cids = append(cids, string(cidBytes))
|
|
}
|
|
}
|
|
return cids, len(cids) > 0
|
|
}
|