Skip to content

Commit

Permalink
Add query osmosis arithmetic twap for interchaintest.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnv1 committed Jan 24, 2024
1 parent bc5ac95 commit 4f07e20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
27 changes: 21 additions & 6 deletions tests/interchaintest/feeabs/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"

feeabstypes "github.com/osmosis-labs/fee-abstraction/v7/x/feeabs/types"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
)

Expand Down Expand Up @@ -41,19 +42,33 @@ func QueryHostZoneConfig(c *cosmos.CosmosChain, ctx context.Context) (*HostChain
return &hostZoneConfig, nil
}

func QueryModuleAccountBalances(c *cosmos.CosmosChain, ctx context.Context) (*QueryFeeabsModuleBalacesResponse, error) {
func QueryModuleAccountBalances(c *cosmos.CosmosChain, ctx context.Context) (*feeabstypes.QueryFeeabsModuleBalacesResponse, error) {
tn := getFullNode(c)
cmd := []string{"feeabs", "module-balances"}
stdout, _, err := tn.ExecQuery(ctx, cmd...)
if err != nil {
return &QueryFeeabsModuleBalacesResponse{}, err
return &feeabstypes.QueryFeeabsModuleBalacesResponse{}, err
}

var feeabsModule QueryFeeabsModuleBalacesResponse
err = json.Unmarshal(stdout, &feeabsModule)
var response feeabstypes.QueryFeeabsModuleBalacesResponse
if err = json.Unmarshal(stdout, &response); err != nil {
return &feeabstypes.QueryFeeabsModuleBalacesResponse{}, err
}

return &response, nil
}

func QueryOsmosisArithmeticTwap(c *cosmos.CosmosChain, ctx context.Context, ibcDenom string) (*feeabstypes.QueryOsmosisArithmeticTwapResponse, error) {
node := getFullNode(c)
cmd := []string{"feeabs", "osmo-arithmetic-twap", ibcDenom}
stdout, _, err := node.ExecQuery(ctx, cmd...)
if err != nil {
return &QueryFeeabsModuleBalacesResponse{}, err
return &feeabstypes.QueryOsmosisArithmeticTwapResponse{}, err
}

return &feeabsModule, nil
var response feeabstypes.QueryOsmosisArithmeticTwapResponse
if err = json.Unmarshal(stdout, &response); err != nil {
return &feeabstypes.QueryOsmosisArithmeticTwapResponse{}, err
}
return &response, nil
}
16 changes: 0 additions & 16 deletions tests/interchaintest/feeabs/types.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package feeabs

import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

type HostChainFeeAbsConfigResponse struct {
HostChainConfig HostChainFeeAbsConfig `json:"host_chain_config"`
}
Expand All @@ -14,15 +10,3 @@ type HostChainFeeAbsConfig struct {
PoolId string `json:"pool_id"`
Frozen bool `json:"frozen"`
}

type AddHostZoneProposalType struct {
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
HostChainConfig HostChainFeeAbsConfig `protobuf:"bytes,3,opt,name=host_chain_config,json=hostChainConfig,proto3" json:"host_chain_config,omitempty"`
Deposit string `json:"deposit"`
}

type QueryFeeabsModuleBalacesResponse struct {
Balances sdk.Coins
Address string
}

0 comments on commit 4f07e20

Please sign in to comment.