Skip to content

Commit

Permalink
Merge branch 'main' into justin/penumbra-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups authored Mar 29, 2024
2 parents ab0ad1d + 65d4330 commit aae1788
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func queryCmd(a *appState) *cobra.Command {
queryIBCDenoms(a),
queryBaseDenomFromIBCDenom(a),
feegrantQueryCmd(a),
queryIBCDenomHash(a),
)

return cmd
Expand Down Expand Up @@ -123,6 +124,7 @@ $ %s q denom-trace osmosis 9BBA9A1C257E971E38C1422780CE6F0B0686F0A3085E2D61118D9
if !ok {
return errChainNotFound(args[0])
}

res, err := c.ChainProvider.QueryDenomTrace(cmd.Context(), args[1])
if err != nil {
return err
Expand All @@ -136,6 +138,35 @@ $ %s q denom-trace osmosis 9BBA9A1C257E971E38C1422780CE6F0B0686F0A3085E2D61118D9
return cmd
}

func queryIBCDenomHash(a *appState) *cobra.Command {
cmd := &cobra.Command{
Use: "denom-hash chain_id trace",
Short: "query the denom hash info from a given denom trace",
Args: withUsage(cobra.ExactArgs(2)),
Example: strings.TrimSpace(fmt.Sprintf(`
$ %s query denom-hash osmosis transfer/channel-0/uatom
$ %s q denom-hash osmosis transfer/channel-0/uatom`,
appName, appName,
)),
RunE: func(cmd *cobra.Command, args []string) error {
c, ok := a.config.Chains[args[0]]
if !ok {
return errChainNotFound(args[0])
}

res, err := c.ChainProvider.QueryDenomHash(cmd.Context(), args[1])
if err != nil {
return err
}

fmt.Fprintln(cmd.OutOrStdout(), res)
return nil
},
}
cmd = addOutputFlag(a.viper, cmd)
return cmd
}

func queryTx(a *appState) *cobra.Command {
cmd := &cobra.Command{
Use: "tx chain_name tx_hash",
Expand Down
16 changes: 16 additions & 0 deletions relayer/chains/cosmos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ func (cc *CosmosProvider) QueryDenomTrace(ctx context.Context, denom string) (*t
if err != nil {
return nil, err
}

return transfers.DenomTrace, nil
}

Expand Down Expand Up @@ -1245,6 +1246,21 @@ func (cc *CosmosProvider) QueryDenomTraces(ctx context.Context, offset, limit ui
return transfers, nil
}

func (cc *CosmosProvider) QueryDenomHash(ctx context.Context, trace string) (string, error) {
qc := transfertypes.NewQueryClient(cc)

req := &transfertypes.QueryDenomHashRequest{
Trace: trace,
}

resp, err := qc.DenomHash(ctx, req, nil)
if err != nil {
return "", err
}

return resp.Hash, nil
}

func (cc *CosmosProvider) QueryStakingParams(ctx context.Context) (*stakingtypes.Params, error) {
res, err := stakingtypes.NewQueryClient(cc).Params(ctx, &stakingtypes.QueryParamsRequest{})
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions relayer/chains/penumbra/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,10 @@ func (cc *PenumbraProvider) QueryDenomTraces(ctx context.Context, offset, limit
return transfers.DenomTraces, nil
}

func (cc *PenumbraProvider) QueryDenomHash(ctx context.Context, trace string) (string, error) {
panic("not implemented")
}

func (cc *PenumbraProvider) QueryStakingParams(ctx context.Context) (*stakingtypes.Params, error) {
res, err := stakingtypes.NewQueryClient(cc).Params(ctx, &stakingtypes.QueryParamsRequest{})
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions relayer/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ type QueryProvider interface {
// ics 20 - transfer
QueryDenomTrace(ctx context.Context, denom string) (*transfertypes.DenomTrace, error)
QueryDenomTraces(ctx context.Context, offset, limit uint64, height int64) ([]transfertypes.DenomTrace, error)
QueryDenomHash(ctx context.Context, trace string) (string, error)
}

type RelayPacket interface {
Expand Down

0 comments on commit aae1788

Please sign in to comment.