Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename admin module bindings #112

Merged
merged 3 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
8 changes: 4 additions & 4 deletions wasmbinding/bindings/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type NeutronMsg struct {
UpdateInterchainQuery *UpdateInterchainQuery `json:"update_interchain_query,omitempty"`
RemoveInterchainQuery *RemoveInterchainQuery `json:"remove_interchain_query,omitempty"`
IBCTransfer *transferwrappertypes.MsgTransfer `json:"ibc_transfer,omitempty"`
SubmitProposal *SubmitProposal `json:"submit_proposal,omitempty"`
SubmitAdminProposal *SubmitAdminProposal `json:"submit_admin_proposal,omitempty"`
}

// SubmitTx submits interchain transaction on a remote chain.
Expand Down Expand Up @@ -70,11 +70,11 @@ type AddAdmin struct {

type AddAdminResponse struct{}

type SubmitProposal struct {
Proposals Proposals `json:"proposals"`
type SubmitAdminProposal struct {
AdminProposal AdminProposal `json:"admin_proposal"`
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
}

type Proposals struct {
type AdminProposal struct {
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
ParamChangeProposal *ParamChangeProposal `json:"param_change_proposal,omitempty"`
}

Expand Down
20 changes: 10 additions & 10 deletions wasmbinding/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre
if contractMsg.IBCTransfer != nil {
return m.ibcTransfer(ctx, contractAddr, *contractMsg.IBCTransfer)
}
if contractMsg.SubmitProposal != nil {
return m.submitProposal(ctx, contractAddr, contractMsg.SubmitProposal)
if contractMsg.SubmitAdminProposal != nil {
return m.submitAdminProposal(ctx, contractAddr, contractMsg.SubmitAdminProposal)
}
}

Expand Down Expand Up @@ -243,10 +243,10 @@ func (m *CustomMessenger) submitTx(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, [][]byte{data}, nil
}

func (m *CustomMessenger) submitProposal(ctx sdk.Context, contractAddr sdk.AccAddress, submitProposal *bindings.SubmitProposal) ([]sdk.Event, [][]byte, error) {
response, err := m.PerformSubmitProposal(ctx, contractAddr, submitProposal)
func (m *CustomMessenger) submitAdminProposal(ctx sdk.Context, contractAddr sdk.AccAddress, submitAdminProposal *bindings.SubmitAdminProposal) ([]sdk.Event, [][]byte, error) {
response, err := m.PerformSubmitAdminProposal(ctx, contractAddr, submitAdminProposal)
if err != nil {
ctx.Logger().Debug("PerformSubmitTx: failed to submitProposal",
ctx.Logger().Debug("PerformSubmitTx: failed to submitAdminProposal",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PerformSubmitTx -> PerformSubmitAdminProposal

"from_address", contractAddr.String(),
"creator", contractAddr.String(),
"error", err,
Expand All @@ -256,7 +256,7 @@ func (m *CustomMessenger) submitProposal(ctx sdk.Context, contractAddr sdk.AccAd

data, err := json.Marshal(response)
if err != nil {
ctx.Logger().Error("json.Marshal: failed to marshal submitProposal response to JSON",
ctx.Logger().Error("json.Marshal: failed to marshal submitAdminProposal response to JSON",
"from_address", contractAddr.String(),
"creator", contractAddr.String(),
"error", err,
Expand All @@ -271,11 +271,11 @@ func (m *CustomMessenger) submitProposal(ctx sdk.Context, contractAddr sdk.AccAd
return nil, [][]byte{data}, nil
}

func (m *CustomMessenger) PerformSubmitProposal(ctx sdk.Context, contractAddr sdk.AccAddress, submitProposal *bindings.SubmitProposal) (*admintypes.MsgSubmitProposalResponse, error) {
func (m *CustomMessenger) PerformSubmitAdminProposal(ctx sdk.Context, contractAddr sdk.AccAddress, submitAdminProposal *bindings.SubmitAdminProposal) (*admintypes.MsgSubmitProposalResponse, error) {
quasisamurai marked this conversation as resolved.
Show resolved Hide resolved
msg := admintypes.MsgSubmitProposal{Proposer: contractAddr.String()}

if submitProposal.Proposals.ParamChangeProposal != nil {
proposal := submitProposal.Proposals.ParamChangeProposal
if submitAdminProposal.AdminProposal.ParamChangeProposal != nil {
proposal := submitAdminProposal.AdminProposal.ParamChangeProposal
prop := paramChange.ParameterChangeProposal{
Title: proposal.Title,
Description: proposal.Description,
Expand All @@ -290,7 +290,7 @@ func (m *CustomMessenger) PerformSubmitProposal(ctx sdk.Context, contractAddr sd
}

if err := msg.ValidateBasic(); err != nil {
return nil, sdkerrors.Wrap(err, "failed to validate incoming SubmitProposal message")
return nil, sdkerrors.Wrap(err, "failed to validate incoming SubmitAdminProposal message")
}

response, err := m.Adminserver.SubmitProposal(sdk.WrapSDKContext(ctx), &msg)
Expand Down