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

Fix: cronos ica register account connection id #872

Merged
merged 6 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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: 7 additions & 1 deletion usecase/model/icaauth/msg_register_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ type MsgRegisterAccount struct {
Version string `mapstructure:"version" json:"version"`
}

type RawMsgRegisterAccount struct {
type RawChainmainMsgRegisterAccount struct {
Owner string `mapstructure:"owner" json:"owner"`
ConnectionID string `mapstructure:"connectionId" json:"connectionId"`
Version string `mapstructure:"version" json:"version"`
}

type RawMsgRegisterAccount struct {
Owner string `mapstructure:"owner" json:"owner"`
ConnectionID string `mapstructure:"connection_id" json:"connection_id"`
Version string `mapstructure:"version" json:"version"`
}
22 changes: 17 additions & 5 deletions usecase/parser/icaauth/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ func ParseChainmainMsgSubmitTx(
func ParseChainmainMsgRegisterAccount(
parserParams utils.CosmosParserParams,
) ([]command.Command, []string) {
var rawMsg icaauth_model.RawMsgRegisterAccount
var rawMsg icaauth_model.RawChainmainMsgRegisterAccount
if err := mapstructure_utils.DefaultMapstructureDecoder.Decode(parserParams.Msg, &rawMsg); err != nil {
panic(fmt.Errorf("error decoding RawMsgRegisterAccount: %v", err))
panic(fmt.Errorf("error decoding RawChainmainMsgRegisterAccount: %v", err))
}

var msgRegisterAccount icaauth_model.MsgRegisterAccount
msg, err := json.Marshal(rawMsg)
if err != nil {
panic(fmt.Errorf("error json marshalling RawMsgRegisterAccount: %v", err))
panic(fmt.Errorf("error json marshalling RawChainmainMsgRegisterAccount: %v", err))
}

err = json.Unmarshal(msg, &msgRegisterAccount)
Expand Down Expand Up @@ -284,10 +284,22 @@ func ParseMsgRegisterAccount(
panic(fmt.Errorf("error decoding RawMsgRegisterAccount: %v", err))
}

rawMsgRegisterAccount, err := json.MarshalIndent(icaauth_model.RawChainmainMsgRegisterAccount(rawMsg), "", " ")
if err != nil {
panic(fmt.Errorf("error json marshalling RawChainmainMsgRegisterAccount: %v", err))
}

var rawChainmainMsgRegisterAccount icaauth_model.RawChainmainMsgRegisterAccount
err = json.Unmarshal(rawMsgRegisterAccount, &rawChainmainMsgRegisterAccount)
if err != nil {
panic(fmt.Errorf("error json unmarshalling RawChainmainMsgRegisterAccount: %v", err))
}

var msgRegisterAccount icaauth_model.MsgRegisterAccount
msg, err := json.Marshal(rawMsg)
var msg []byte
msg, err = json.Marshal(rawChainmainMsgRegisterAccount)
if err != nil {
panic(fmt.Errorf("error json marshalling RawMsgRegisterAccount: %v", err))
panic(fmt.Errorf("error json marshalling RawChainmainMsgRegisterAccount: %v", err))
}

err = json.Unmarshal(msg, &msgRegisterAccount)
Expand Down
2 changes: 1 addition & 1 deletion usecase/parser/msg_register_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var _ = Describe("ParseMsgCommands", func() {
"msgIndex": 0,
"params": {
"owner": "tcro1np7ztcfeycqwhj0nr8hxfu0lfjz27telqx53ra",
"connectionId": "",
"connectionId": "connection-18",
"version": "",
"portId": "icacontroller-tcro1np7ztcfeycqwhj0nr8hxfu0lfjz27telqx53ra",
"channelId": "channel-48",
Expand Down
Loading