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: bridge module cli #185

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion proto/realionetwork/bridge/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ message MsgBridgeIn {
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
string reciever = 3;
string receiver = 3;
}

message MsgBridgeInResponse {}
Expand All @@ -45,6 +45,7 @@ message MsgBridgeOut {
message MsgBridgeOutResponse {}

message MsgRegisterNewCoins {
option (cosmos.msg.v1.signer) = "authority";
string authority = 1;
repeated cosmos.base.v1beta1.Coin coins = 2 [
(gogoproto.nullable) = false,
Expand Down
19 changes: 13 additions & 6 deletions x/bridge/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func GetTxCmd() *cobra.Command {

func CmdBridgeIn() *cobra.Command {
cmd := &cobra.Command{
Use: "bridge-in [amount]",
Use: "bridge-in [amount] [receiver]",
Short: "Broadcast message BridgeIn",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand All @@ -52,9 +52,15 @@ func CmdBridgeIn() *cobra.Command {
return err
}

_, err = sdk.AccAddressFromBech32(args[1])
if err != nil {
return err
}

msg := &types.MsgBridgeIn{
Authority: clientCtx.GetFromAddress().String(),
Coin: coin,
Receiver: args[1],
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
Expand Down Expand Up @@ -112,7 +118,7 @@ func CmdDeregisterCoins() *cobra.Command {
}

var denoms []string
denoms = append(denoms, args[0:len(args)-1]...)
denoms = append(denoms, args...)

msg := &types.MsgDeregisterCoins{
Authority: clientCtx.GetFromAddress().String(),
Expand All @@ -129,9 +135,10 @@ func CmdDeregisterCoins() *cobra.Command {

func CmdRegisterNewCoins() *cobra.Command {
cmd := &cobra.Command{
Use: "register-coins [amount]",
Short: "Broadcast message RegisterNewCoins",
Args: cobra.ExactArgs(1),
Use: "register-coins [amount]",
Short: "Broadcast message RegisterNewCoins",
Example: "realio-networkd tx bridge register-coins 100denoma,200denomb",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/bridge/keeper/msg_server_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (ms msgServer) BridgeIn(goCtx context.Context, msg *types.MsgBridgeIn) (*ty
}

addrCodec := ms.authKeeper.AddressCodec()
accAddr, err := addrCodec.StringToBytes(msg.Reciever)
accAddr, err := addrCodec.StringToBytes(msg.Receiver)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/bridge/keeper/msg_server_bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (suite *KeeperTestSuite) TestBridgeIn() {

if tc.setAuthority {
tc.msg.Authority = suite.admin
tc.msg.Reciever = suite.admin
tc.msg.Receiver = suite.admin
}

addr, err := suite.app.AccountKeeper.AddressCodec().StringToBytes(tc.msg.Authority)
Expand Down
112 changes: 56 additions & 56 deletions x/bridge/types/tx.pb.go

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

Loading