Skip to content

Commit

Permalink
refactor: consistent module service methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanchristo committed Sep 6, 2024
1 parent 44b8720 commit 93d12fd
Show file tree
Hide file tree
Showing 43 changed files with 998 additions and 1,350 deletions.
91 changes: 46 additions & 45 deletions admin/api/v1/state.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion admin/genesis/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestValidateGenesis(t *testing.T) {
{
name: "valid",
setup: func(ctx context.Context, ss adminv1.StateStore) {
require.NoError(t, ss.AdminTable().Save(ctx, &adminv1.Admin{Admin: []byte("BTZfSbi0JKqguZ/tIAPUIhdAa7Y=")}))
require.NoError(t, ss.AdminTable().Save(ctx, &adminv1.Admin{Address: []byte("BTZfSbi0JKqguZ/tIAPUIhdAa7Y=")}))
},
},
}
Expand Down
12 changes: 6 additions & 6 deletions admin/keeper/msg_update_admin.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Msg/UpdateAdmin

UpdateAdmin is successful when:
- admin is the admin account
- admin is admin account

UpdateAdmin has the following outcomes:
- message response returned
Expand All @@ -14,7 +14,7 @@ Feature: Msg/UpdateAdmin
Given admin
"""
{
"admin": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
"address": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
}
"""

Expand Down Expand Up @@ -47,7 +47,7 @@ Feature: Msg/UpdateAdmin
Given admin
"""
{
"admin": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
"address": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
}
"""

Expand Down Expand Up @@ -75,7 +75,7 @@ Feature: Msg/UpdateAdmin
Given admin
"""
{
"admin": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
"address": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
}
"""

Expand All @@ -90,7 +90,7 @@ Feature: Msg/UpdateAdmin
Then expect state admin
"""
{
"admin": "hEyiXxUCaFQmkbuhO9r+QDscjIY="
"address": "hEyiXxUCaFQmkbuhO9r+QDscjIY="
}
"""

Expand All @@ -102,7 +102,7 @@ Feature: Msg/UpdateAdmin
Given admin
"""
{
"admin": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
"address": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
}
"""

Expand Down
8 changes: 4 additions & 4 deletions admin/keeper/msg_update_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func (k Keeper) UpdateAdmin(ctx context.Context, req *v1.MsgUpdateAdmin) (*v1.Ms
}

// get account from account bytes
adminAdmin := sdk.AccAddress(admin.Admin)
stateAdmin := sdk.AccAddress(admin.Address)

// verify admin is admin account
if !reqAdmin.Equals(adminAdmin) {
if !reqAdmin.Equals(stateAdmin) {
return nil, sdkerrors.ErrUnauthorized.Wrapf(
"admin %s: admin account %s", reqAdmin, adminAdmin,
"admin %s: admin account %s", reqAdmin, stateAdmin,
)
}

Expand All @@ -46,7 +46,7 @@ func (k Keeper) UpdateAdmin(ctx context.Context, req *v1.MsgUpdateAdmin) (*v1.Ms
}

// set new admin
admin.Admin = newAdmin
admin.Address = newAdmin

// update admin in admin table
err = k.ss.AdminTable().Save(ctx, admin)
Expand Down
4 changes: 2 additions & 2 deletions admin/keeper/msg_update_admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *msgUpdateAdmin) Admin(a gocuke.DocString) {
require.NoError(s.t, err)

err = s.k.ss.AdminTable().Save(s.sdkCtx, &adminv1.Admin{
Admin: admin.Admin,
Address: admin.Address,
})
require.NoError(s.t, err)
}
Expand Down Expand Up @@ -71,7 +71,7 @@ func (s *msgUpdateAdmin) ExpectStateAdmin(a gocuke.DocString) {
actual, err := s.k.ss.AdminTable().Get(s.sdkCtx)
require.NoError(s.t, err)

require.Equal(s.t, expected.Admin, actual.Admin)
require.Equal(s.t, expected.Address, actual.Address)
}

func (s *msgUpdateAdmin) ExpectEventUpdate(a gocuke.DocString) {
Expand Down
2 changes: 1 addition & 1 deletion admin/keeper/query_admin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Query/Admin
Given admin
"""
{
"admin": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
"address": "BTZfSbi0JKqguZ/tIAPUIhdAa7Y="
}
"""

Expand Down
2 changes: 1 addition & 1 deletion admin/keeper/query_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (k Keeper) Admin(ctx context.Context, req *v1.QueryAdminRequest) (*v1.Query
}

// get account from account bytes
curator := sdk.AccAddress(admin.Admin)
curator := sdk.AccAddress(admin.Address)

// return query response
return &v1.QueryAdminResponse{
Expand Down
2 changes: 1 addition & 1 deletion admin/keeper/query_admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *queryAdmin) Admin(a gocuke.DocString) {
require.NoError(s.t, err)

err = s.k.ss.AdminTable().Save(s.sdkCtx, &adminv1.Admin{
Admin: admin.Admin,
Address: admin.Address,
})
require.NoError(s.t, err)
}
Expand Down
4 changes: 2 additions & 2 deletions admin/proto/v1/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ message Admin {
id : 1,
};

// admin is the address of the admin account.
bytes admin = 1;
// address is the address of the admin account.
bytes address = 1;
}
Loading

0 comments on commit 93d12fd

Please sign in to comment.