From 4f07e2095555e36be7891badc8f96cf84a34f3c7 Mon Sep 17 00:00:00 2001 From: tnv1 Date: Wed, 24 Jan 2024 13:59:04 +0700 Subject: [PATCH] Add query osmosis arithmetic twap for interchaintest. --- tests/interchaintest/feeabs/query.go | 27 +++++++++++++++++++++------ tests/interchaintest/feeabs/types.go | 16 ---------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/interchaintest/feeabs/query.go b/tests/interchaintest/feeabs/query.go index b48e4730..b4f79500 100644 --- a/tests/interchaintest/feeabs/query.go +++ b/tests/interchaintest/feeabs/query.go @@ -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" ) @@ -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 } diff --git a/tests/interchaintest/feeabs/types.go b/tests/interchaintest/feeabs/types.go index a21328ae..c7c255fa 100644 --- a/tests/interchaintest/feeabs/types.go +++ b/tests/interchaintest/feeabs/types.go @@ -1,9 +1,5 @@ package feeabs -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - type HostChainFeeAbsConfigResponse struct { HostChainConfig HostChainFeeAbsConfig `json:"host_chain_config"` } @@ -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 -}