-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [CT-834] new endpoint for stateful orders * fix test * indexer (cherry picked from commit c24be3a) Co-authored-by: jayy04 <[email protected]>
- Loading branch information
1 parent
cae35bc
commit edbcd22
Showing
10 changed files
with
975 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/clob/types" | ||
satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" | ||
"github.com/spf13/cast" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func CmdQueryStatefulOrder() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "stateful-order subaccount_owner subaccount_number client_id clob_pair_id order_flags", | ||
Short: "queries a stateful order by id", | ||
Args: cobra.ExactArgs(5), | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
clientCtx := client.GetClientContextFromCmd(cmd) | ||
|
||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
owner := args[0] | ||
|
||
number, err := cast.ToUint32E(args[1]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
clientId, err := cast.ToUint32E(args[2]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
clobPairId, err := cast.ToUint32E(args[3]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
orderFlag, err := cast.ToUint32E(args[4]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
req := &types.QueryStatefulOrderRequest{ | ||
OrderId: types.OrderId{ | ||
SubaccountId: satypes.SubaccountId{ | ||
Owner: owner, | ||
Number: number, | ||
}, | ||
ClientId: clientId, | ||
ClobPairId: clobPairId, | ||
OrderFlags: orderFlag, | ||
}, | ||
} | ||
|
||
res, err := queryClient.StatefulOrder(context.Background(), req) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
Oops, something went wrong.