Skip to content

Commit

Permalink
feat: Rename MsgAuthenticateResponse to MsgAuthenticateControllerResp…
Browse files Browse the repository at this point in the history
…onse

Renamed MsgAuthenticateResponse to MsgAuthenticateControllerResponse for
consistency with controller naming convention. Updated corresponding
references and methods.
  • Loading branch information
prnk28 committed Jun 18, 2024
1 parent ced3af9 commit c41b489
Show file tree
Hide file tree
Showing 9 changed files with 382 additions and 340 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.dylib
*.app
.DS_Store
.session.vim

# Test binary
*.test
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine AS go-builder
FROM golang:1.22-alpine AS go-builder

SHELL ["/bin/sh", "-ecuxo", "pipefail"]

Expand Down
415 changes: 209 additions & 206 deletions api/did/v1/tx.pulsar.go

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions api/did/v1/tx_grpc.pb.go

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

14 changes: 9 additions & 5 deletions proto/did/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ service Msg {
// InitializeController initializes a controller with the given assertions, keyshares, and verifications.
rpc InitializeController(MsgInitializeController) returns (MsgInitializeControllerResponse);

// Authenticate asserts the given controller is the owner of the given address.
rpc Authenticate(MsgAuthenticate) returns (MsgAuthenticateResponse);
// AuthenticateController asserts the given controller is the owner of the given address.
rpc AuthenticateController(MsgAuthenticateController) returns (MsgAuthenticateControllerResponse);
}

// MsgUpdateParams is the Msg/UpdateParams request type.
Expand Down Expand Up @@ -68,7 +68,7 @@ message MsgInitializeControllerResponse {
}

// MsgAuthenticate is the message type for the Authenticate RPC.
message MsgAuthenticate {
message MsgAuthenticateController {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address of the governance account.
Expand All @@ -79,7 +79,11 @@ message MsgAuthenticate {

// Address is the address to authenticate.
string address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// Origin is the origin of the request in wildcard form.
string origin = 4;
}

// MsgAuthenticateResponse is the response type for the Authenticate RPC.
message MsgAuthenticateResponse {}
// MsgAuthenticateControllerResponse is the response type for the Authenticate RPC.
message MsgAuthenticateControllerResponse {}

2 changes: 1 addition & 1 deletion x/did/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

// "github.com/di-dao/sonr/internal/local"
"github.com/di-dao/sonr/x/did/types"
)

Expand Down Expand Up @@ -39,7 +40,6 @@ func (k Querier) LoginOptions(goCtx context.Context, req *types.QueryLoginOption

// RegisterOptions implements types.QueryServer.
func (k Querier) RegisterOptions(goCtx context.Context, req *types.QueryRegisterOptionsRequest) (*types.QueryRegisterOptionsResponse, error) {
// ctx := sdk.UnwrapSDKContext(goCtx)
panic("RegisterOptions is unimplemented")
return &types.QueryRegisterOptionsResponse{}, nil
}
Expand Down
25 changes: 13 additions & 12 deletions x/did/keeper/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{k: keeper}
}

func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if ms.k.authority != msg.Authority {
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority)
}

return nil, ms.k.Params.Set(ctx, msg.Params)
}

// InitializeController implements types.MsgServer.
func (ms msgServer) InitializeController(goCtx context.Context, msg *types.MsgInitializeController) (*types.MsgInitializeControllerResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
Expand Down Expand Up @@ -63,9 +55,18 @@ func (ms msgServer) InitializeController(goCtx context.Context, msg *types.MsgIn
return &types.MsgInitializeControllerResponse{}, nil
}

// Authenticate implements types.MsgServer.
func (ms msgServer) Authenticate(ctx context.Context, msg *types.MsgAuthenticate) (*types.MsgAuthenticateResponse, error) {
// UpdateParams updates the x/did module parameters.
func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if ms.k.authority != msg.Authority {
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority)
}

return nil, ms.k.Params.Set(ctx, msg.Params)
}

// AuthenticateController implements types.MsgServer.
func (ms msgServer) AuthenticateController(ctx context.Context, msg *types.MsgAuthenticateController) (*types.MsgAuthenticateControllerResponse, error) {
// ctx := sdk.UnwrapSDKContext(goCtx)
panic("Authenticate is unimplemented")
return &types.MsgAuthenticateResponse{}, nil
panic("AuthenticateController is unimplemented")
return &types.MsgAuthenticateControllerResponse{}, nil
}
32 changes: 32 additions & 0 deletions x/did/types/account_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"bytes"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -54,11 +56,31 @@ func ProtoAccount() authtypes.AccountI {
}
}

// GetAccountNumber returns account number.
func (acc EthAccount) GetAccountNumber() uint64 {
return acc.BaseAccount.AccountNumber
}

// GetAddress returns account address.
func (acc EthAccount) GetAddress() sdk.AccAddress {
return acc.BaseAccount.Address
}

// GetBaseAccount returns base account.
func (acc EthAccount) GetBaseAccount() *authtypes.BaseAccount {
return acc.BaseAccount
}

// GetPubKey returns the PubKey
func (acc EthAccount) GetPubKey() cryptotypes.PubKey {
return acc.BaseAccount.PubKey
}

// GetSequence returns the sequence
func (acc EthAccount) GetSequence() uint64 {
return acc.BaseAccount.Sequence
}

// EthAddress returns the account address ethereum format.
func (acc EthAccount) EthAddress() common.Address {
return common.BytesToAddress(acc.GetAddress().Bytes())
Expand All @@ -69,6 +91,11 @@ func (acc EthAccount) GetCodeHash() common.Hash {
return common.HexToHash(acc.CodeHash)
}

// SetAccountNumber sets the account number
func (acc *EthAccount) SetAccountNumber(accNum uint64) {
acc.BaseAccount.AccountNumber = accNum
}

// SetCodeHash sets the account code hash to the EthAccount fields
func (acc *EthAccount) SetCodeHash(codeHash common.Hash) error {
acc.CodeHash = codeHash.Hex()
Expand All @@ -82,3 +109,8 @@ func (acc EthAccount) Type() int8 {
}
return AccountTypeContract
}

// Stringreturns the string representation of the EthAccount
func (acc EthAccount) String() string {
return acc.EthAddress().String()
}
Loading

0 comments on commit c41b489

Please sign in to comment.