From 5d544df0d769c62c0ef3584b84416182d9495819 Mon Sep 17 00:00:00 2001 From: freqnik Date: Mon, 13 Nov 2023 03:18:46 -0500 Subject: [PATCH 1/3] Return nil session on StatusInactivePending --- .project | 11 +++++++++++ cmd/connect.go | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 0000000..934c6c1 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + cli-client + + + + + + + + diff --git a/cmd/connect.go b/cmd/connect.go index e162869..ef9a8dd 100644 --- a/cmd/connect.go +++ b/cmd/connect.go @@ -99,7 +99,11 @@ func queryActiveSession(qsc sessiontypes.QueryServiceClient, address sdk.AccAddr return nil, err } if len(result.Sessions) > 0 { - return &result.Sessions[0], nil + if result.Sessions[0].Status == hubtypes.StatusInactivePending { + return nil, nil + } else { + return &result.Sessions[0], nil + } } return nil, nil @@ -123,7 +127,10 @@ func ConnectCmd() *cobra.Command { address, err := hubtypes.NodeAddressFromBech32(args[1]) if err != nil { + message := fmt.Sprintf("%s", err) + fmt.Println(message) return err + } timeout, err := cmd.Flags().GetDuration(clienttypes.FlagTimeout) @@ -207,11 +214,13 @@ func ConnectCmd() *cobra.Command { sessionQueryClient = sessiontypes.NewQueryServiceClient(ctx) ) + // This is where it finds the inactive_pending session, session.ID session, err := queryActiveSession(sessionQueryClient, ctx.FromAddress) if err != nil { return err } + // Add a MsgEndRequest if session is active if session != nil { messages = append( messages, @@ -240,6 +249,7 @@ func ConnectCmd() *cobra.Command { if err != nil { return err } + if session == nil { return errors.New("no active session found") } From 22dd3487cca193b42e7c4b61fc8f95fdf2754916 Mon Sep 17 00:00:00 2001 From: freqnik Date: Mon, 13 Nov 2023 03:21:49 -0500 Subject: [PATCH 2/3] Return nil session on StatusInactivePending --- cmd/connect.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmd/connect.go b/cmd/connect.go index ef9a8dd..56a6d3a 100644 --- a/cmd/connect.go +++ b/cmd/connect.go @@ -127,10 +127,7 @@ func ConnectCmd() *cobra.Command { address, err := hubtypes.NodeAddressFromBech32(args[1]) if err != nil { - message := fmt.Sprintf("%s", err) - fmt.Println(message) return err - } timeout, err := cmd.Flags().GetDuration(clienttypes.FlagTimeout) @@ -214,7 +211,6 @@ func ConnectCmd() *cobra.Command { sessionQueryClient = sessiontypes.NewQueryServiceClient(ctx) ) - // This is where it finds the inactive_pending session, session.ID session, err := queryActiveSession(sessionQueryClient, ctx.FromAddress) if err != nil { return err From 8d765273c12d5bad1874e6a2020d5cc2bb2d4a68 Mon Sep 17 00:00:00 2001 From: freqnik Date: Mon, 13 Nov 2023 03:23:04 -0500 Subject: [PATCH 3/3] Return nil session on StatusInactivePending --- .project | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index 934c6c1..0000000 --- a/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - cli-client - - - - - - - -