Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
09b6d23
feature(collections-name-module): updated name module kvstore to coll…
nagarajdivine Jul 20, 2025
2c62aff
feature(collections-name-module): updated collection in app.go and in…
nagarajdivine Jul 23, 2025
8beb6ff
feature(collections-name-module): added keycodec to address index and…
nagarajdivine Jul 24, 2025
f09c542
feature(collections-name-module): added migration method
nagarajdivine Jul 25, 2025
8a9f334
feature(collections-name-module): added mogations method and confgiur…
nagarajdivine Jul 28, 2025
c1b62fb
feature(collections-name-module): added entry for collections in upgr…
nagarajdivine Jul 29, 2025
65cc950
feature(collections-name-module): fixed lint issue
nagarajdivine Jul 29, 2025
ef6f129
feature(collections-name-module): rebased to main and resolved all su…
nagarajdivine Jul 31, 2025
6496115
feature(collections-name-module): fix lint issue
nagarajdivine Jul 31, 2025
ee0f0e3
feature(collections-name-module): added changelog with changes made i…
nagarajdivine Jul 31, 2025
22ce26e
feature(collections-name-module): update name keeper to use IndexMap,…
nagarajdivine Aug 4, 2025
04dc49e
feature(collections-name-module): name module updated from collection…
nagarajdivine Aug 7, 2025
9a28c31
feature(collections-name-module): fixed test cases,updated reverse lo…
nagarajdivine Aug 7, 2025
8465deb
feature(collections-name-module): rebased main and fixed the lint issue
nagarajdivine Aug 8, 2025
b0525de
feature(collections-name-module): fixed lint issue
nagarajdivine Aug 8, 2025
0c7e575
feature(collections-name-module): added comment G115 for safe conversion
nagarajdivine Aug 8, 2025
aad1cea
feature(collections-name-module): removed log from migration
nagarajdivine Aug 8, 2025
1de7aa2
feature(collections-name-module): rebased main and fix all suggestion…
nagarajdivine Sep 24, 2025
c8e64a7
feature(collections-name-module): fixed query and getrecordbyaddress
nagarajdivine Sep 25, 2025
6e1a93f
feature(collections-name-module): fix test cases
nagarajdivine Sep 29, 2025
a323e50
feature(collections-name-module): fix ReverseLookup query by address …
nagarajdivine Oct 2, 2025
d64adbe
feature(collections-name-module): rebase to main
nagarajdivine Oct 6, 2025
d474692
rebase onto main and fix lint
nagarajdivine Feb 12, 2026
ce83a36
fix test case
nagarajdivine Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Migrated name module from kv-store to collections [#2411](https://github.com/provenance-io/provenance/issues/2411).
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func New(
hooksTransferModule := ibchooks.NewIBCMiddleware(app.RateLimitMiddleware, &app.HooksICS4Wrapper)
app.TransferStack = &hooksTransferModule

app.NameKeeper = namekeeper.NewKeeper(appCodec, keys[nametypes.StoreKey])
app.NameKeeper = namekeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[nametypes.StoreKey]))

app.AttributeKeeper = attributekeeper.NewKeeper(
appCodec, keys[attributetypes.StoreKey], app.AccountKeeper, &app.NameKeeper,
Expand Down
2 changes: 1 addition & 1 deletion internal/provwasm/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func getRandomBondFee(r *rand.Rand, simState module.SimulationState, spendable s
// An error is only returned if there was a problem iterating records.
func getRandomRootNameRecord(r *rand.Rand, ctx sdk.Context, nk namekeeper.Keeper, accs []simtypes.Account) (nametypes.NameRecord, simtypes.Account, bool, error) {
var records []nametypes.NameRecord
err := nk.IterateRecords(ctx, nametypes.NameKeyPrefix, func(record nametypes.NameRecord) error {
err := nk.IterateRecords(ctx, func(record nametypes.NameRecord) error {
if len(record.Address) > 0 && !strings.Contains(record.Name, ".") {
records = append(records, record)
}
Expand Down
6 changes: 3 additions & 3 deletions x/attribute/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,10 +852,10 @@ func (s *KeeperTestSuite) TestGetAttributesByName() {
}
s.Assert().NoError(s.app.AttributeKeeper.SetAttribute(s.ctx, attr, s.user1Addr), "should save successfully")
_, err := s.app.AttributeKeeper.GetAttributes(s.ctx, s.user1, "blah")
s.Assert().Error(err)
s.Assert().Equal("no address bound to name", err.Error())
s.Assert().Error(err, "GetAttributes")
s.Assert().Contains(err.Error(), "no address bound to name")
attributes, err := s.app.AttributeKeeper.GetAttributes(s.ctx, s.user1, "example.attribute")
s.Assert().NoError(err)
s.Assert().NoError(err, "GetAttributes should succeed")
s.Assert().Equal(1, len(attributes))
s.Assert().Equal(attr.Name, attributes[0].Name)
s.Assert().Equal(attr.Address, attributes[0].Address)
Expand Down
4 changes: 2 additions & 2 deletions x/attribute/keeper/mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ func (k *mockNameKeeper) UpdateNameRecord(ctx sdk.Context, name string, addr sdk
}

// IterateRecords calls the parent's IterateRecords function.
func (k *mockNameKeeper) IterateRecords(ctx sdk.Context, prefix []byte, handle func(nametypes.NameRecord) error) error {
return k.Parent.IterateRecords(ctx, prefix, handle)
func (k *mockNameKeeper) IterateRecords(ctx sdk.Context, handle func(nametypes.NameRecord) error) error {
return k.Parent.IterateRecords(ctx, handle)
}
2 changes: 2 additions & 0 deletions x/attribute/keeper/query_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/provenance-io/provenance/x/attribute/types"
markertypes "github.com/provenance-io/provenance/x/marker/types"
metadatatypes "github.com/provenance-io/provenance/x/metadata/types"
nametypes "github.com/provenance-io/provenance/x/name/types"
)

type QueryServerTestSuite struct {
Expand All @@ -44,6 +45,7 @@ func (s *QueryServerTestSuite) SetupTest() {
s.ctx = s.app.BaseApp.NewContext(true)
s.app.AccountKeeper.Params.Set(s.ctx, authtypes.DefaultParams())
s.app.BankKeeper.SetParams(s.ctx, banktypes.DefaultParams())
s.app.NameKeeper.SetParams(s.ctx, nametypes.DefaultParams())
s.cfg = testutil.DefaultTestNetworkConfig()
queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, s.app.AttributeKeeper)
Expand Down
2 changes: 1 addition & 1 deletion x/attribute/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func Dispatch(
// An error is only returned if there was a problem iterating records.
func getRandomNameRecord(r *rand.Rand, ctx sdk.Context, nk types.NameKeeper, accs []simtypes.Account) (nametypes.NameRecord, simtypes.Account, bool, error) {
var records []nametypes.NameRecord
err := nk.IterateRecords(ctx, nametypes.NameKeyPrefix, func(record nametypes.NameRecord) error {
err := nk.IterateRecords(ctx, func(record nametypes.NameRecord) error {
records = append(records, record)
return nil
})
Expand Down
2 changes: 1 addition & 1 deletion x/attribute/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ type NameKeeper interface {
SetAttributeKeeper(attrKeeper nametypes.AttributeKeeper)
SetNameRecord(ctx sdk.Context, name string, addr sdk.AccAddress, restrict bool) error
UpdateNameRecord(ctx sdk.Context, name string, addr sdk.AccAddress, restrict bool) error
IterateRecords(ctx sdk.Context, prefix []byte, handle func(nametypes.NameRecord) error) error
IterateRecords(ctx sdk.Context, handle func(nametypes.NameRecord) error) error
}
4 changes: 2 additions & 2 deletions x/name/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ func (s *IntegrationTestSuite) TestReverseLookupCommand() {
{
"query name, json output",
[]string{s.accountAddr.String(), fmt.Sprintf("--%s=json", cmtcli.OutputFlag)},
"{\"name\":[\"example.attribute\",\"attribute\"],\"pagination\":{\"next_key\":null,\"total\":\"0\"}}",
"{\"name\":[\"attribute\",\"example.attribute\"],\"pagination\":{\"next_key\":null,\"total\":\"0\"}}",
Comment thread
nagarajdivine marked this conversation as resolved.
},
{
"query name, text output",
[]string{s.accountAddr.String(), fmt.Sprintf("--%s=text", cmtcli.OutputFlag)},
"name:\n- example.attribute\n- attribute\npagination:\n next_key: null\n total: \"0\"",
"name:\n- attribute\n- example.attribute\npagination:\n next_key: null\n total: \"0\"",
},
{
"query name that does not exist, text output",
Expand Down
5 changes: 4 additions & 1 deletion x/name/keeper/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ import sdk "github.com/cosmos/cosmos-sdk/types"

// AddRecord is a TEST ONLY exposure of addRecord.
func (k Keeper) AddRecord(ctx sdk.Context, name string, addr sdk.AccAddress, restrict, isModifiable bool) error {
return k.addRecord(ctx, name, addr, restrict, isModifiable)
if isModifiable {
return k.UpdateNameRecord(ctx, name, addr, restrict)
}
return k.SetNameRecord(ctx, name, addr, restrict)
}
29 changes: 16 additions & 13 deletions x/name/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,31 @@ import (
func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) {
k.SetParams(ctx, data.Params)
for _, record := range data.Bindings {
addr, err := sdk.AccAddressFromBech32(record.Address)
if err != nil {
panic(err)
}
if err := k.SetNameRecord(ctx, record.Name, addr, record.Restricted); err != nil {
// Create record directly without normalization checks
if err := k.nameRecords.Set(ctx, record.Name, types.NameRecord{
Name: record.Name,
Address: record.Address,
Restricted: record.Restricted,
}); err != nil {
Comment thread
nagarajdivine marked this conversation as resolved.
panic(err)
}
}
}

// ExportGenesis exports the current keeper state of the name module.
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
// Get module parameters
params := k.GetParams(ctx)
// Genesis state data structure.
records := types.NameRecords{}
// Callback func that adds records to genesis state.
appendToRecords := func(record types.NameRecord) error {
// Collect all name records
records := make(types.NameRecords, 0)

// Iterate through all name records
err := k.nameRecords.Walk(ctx, nil, func(_ string, record types.NameRecord) (bool, error) {
records = append(records, record)
return nil
}
// Collect and return genesis state.
if err := k.IterateRecords(ctx, types.NameKeyPrefix, appendToRecords); err != nil {
return false, nil
})

if err != nil {
panic(err)
}
return types.NewGenesisState(params, records)
Expand Down
Loading
Loading