Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter contract address wasm #117

Merged
merged 5 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
*lumberjack.Logger
}

func (lumberjackSink) Sync() error { return nil }

Check warning on line 181 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L181

Added line #L181 was not covered by tests

func newRootLogger(format string, debug bool) (*zap.Logger, error) {
config := zap.NewProductionEncoderConfig()
Expand All @@ -187,18 +187,18 @@
}
config.LevelKey = "lvl"

ll := lumberjack.Logger{
Filename: path.Join(defaultHome, "relay.log"),
MaxSize: 50, //MB
MaxSize: 10, //MB
MaxBackups: 30,
MaxAge: 28, //days
Compress: true,
Compress: false,
}
zap.RegisterSink("lumberjack", func(*url.URL) (zap.Sink, error) {
return lumberjackSink{
Logger: &ll,
}, nil
})

Check warning on line 201 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L190-L201

Added lines #L190 - L201 were not covered by tests

var enc zapcore.Encoder
switch format {
Expand All @@ -217,13 +217,13 @@
level = zap.DebugLevel
}

w := zapcore.AddSync(&ll)

Check warning on line 220 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L220

Added line #L220 was not covered by tests

core := zapcore.NewTee(
zapcore.NewCore(enc, w, level),

Check warning on line 223 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L223

Added line #L223 was not covered by tests
zapcore.NewCore(enc, os.Stderr, level),
)

Check warning on line 226 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L226

Added line #L226 was not covered by tests
return zap.New(core), nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/configs/chains/ibc-wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"timeout": "20s",
"output-format": "json",
"sign-mode": "direct",
"ibc-handler-address":"--",
"ibc-handler-address":"neutron1fde8lfydxgwg6p7xe9ugx5a6ysj37zfvn9m9z5rxt4mqvdcneczsczq2a4",
"broadcast-mode": "batch",
"block-timeout": "",
"start-height":0,
Expand Down
13 changes: 12 additions & 1 deletion relayer/chains/icon/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"strings"
"time"

"cosmossdk.io/math"
"github.com/avast/retry-go/v4"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"
Expand Down Expand Up @@ -81,12 +82,12 @@

// required for cosmos only
func (icp *IconProvider) QueryTx(ctx context.Context, hashHex string) (*provider.RelayerTxResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 85 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L85

Added line #L85 was not covered by tests
}

// required for cosmos only
func (icp *IconProvider) QueryTxs(ctx context.Context, page, limit int, events []string) ([]*provider.RelayerTxResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 90 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L90

Added line #L90 was not covered by tests
}

func (icp *IconProvider) QueryLatestHeight(ctx context.Context) (int64, error) {
Expand Down Expand Up @@ -125,11 +126,11 @@
}

func (icp *IconProvider) QuerySendPacket(ctx context.Context, srcChanID, srcPortID string, sequence uint64) (provider.PacketInfo, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 129 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L129

Added line #L129 was not covered by tests
}

func (icp *IconProvider) QueryRecvPacket(ctx context.Context, dstChanID, dstPortID string, sequence uint64) (provider.PacketInfo, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 133 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L133

Added line #L133 was not covered by tests
}

func (icp *IconProvider) QueryBalance(ctx context.Context, keyName string) (sdk.Coins, error) {
Expand All @@ -143,7 +144,17 @@

// implementing is not required
func (icp *IconProvider) QueryBalanceWithAddress(ctx context.Context, addr string) (sdk.Coins, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))
param := types.AddressParam{
Address: types.Address(addr),
}
balance, err := icp.client.GetBalance(&param)
if err != nil {
return nil, err
}
return sdk.Coins{sdk.Coin{
Denom: "ICX",
Amount: math.NewInt(balance.Int64()),
}}, nil

Check warning on line 157 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L147-L157

Added lines #L147 - L157 were not covered by tests
}

func (icp *IconProvider) QueryUnbondingPeriod(context.Context) (time.Duration, error) {
Expand Down Expand Up @@ -282,15 +293,15 @@
}

func (icp *IconProvider) QueryUpgradedClient(ctx context.Context, height int64) (*clienttypes.QueryClientStateResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 296 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L296

Added line #L296 was not covered by tests
}

func (icp *IconProvider) QueryUpgradedConsState(ctx context.Context, height int64) (*clienttypes.QueryConsensusStateResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 300 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L300

Added line #L300 was not covered by tests
}

func (icp *IconProvider) QueryConsensusState(ctx context.Context, height int64) (ibcexported.ConsensusState, int64, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 304 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L304

Added line #L304 was not covered by tests
}

// query all the clients of the chain
Expand Down Expand Up @@ -413,7 +424,7 @@
continue
}
// Only return open conenctions
if conn.State == conntypes.OPEN {

Check warning on line 427 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L427

Added line #L427 was not covered by tests
identifiedConn := conntypes.IdentifiedConnection{
Id: connectionId,
ClientId: conn.ClientId,
Expand Down Expand Up @@ -465,7 +476,7 @@
}

func (icp *IconProvider) QueryConnectionsUsingClient(ctx context.Context, height int64, clientid string) (*conntypes.QueryConnectionsResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 479 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L479

Added line #L479 was not covered by tests
}
func (icp *IconProvider) GenerateConnHandshakeProof(ctx context.Context, height int64, clientId, connId string) (ibcexported.ClientState,
[]byte, []byte, []byte,
Expand Down Expand Up @@ -560,7 +571,7 @@
)

func (icp *IconProvider) QueryChannelClient(ctx context.Context, height int64, channelid, portid string) (*clienttypes.IdentifiedClientState, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 574 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L574

Added line #L574 was not covered by tests
}

// is not needed currently for the operation
Expand Down Expand Up @@ -623,7 +634,7 @@
}

// check if the channel is open
if channel.State == chantypes.OPEN {

Check warning on line 637 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L637

Added line #L637 was not covered by tests
identifiedChannel := chantypes.IdentifiedChannel{
State: channel.State,
Ordering: channel.Ordering,
Expand All @@ -643,19 +654,19 @@

// required to flush packets
func (icp *IconProvider) QueryPacketCommitments(ctx context.Context, height uint64, channelid, portid string) (commitments *chantypes.QueryPacketCommitmentsResponse, err error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 657 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L657

Added line #L657 was not covered by tests
}

func (icp *IconProvider) QueryPacketAcknowledgements(ctx context.Context, height uint64, channelid, portid string) (acknowledgements []*chantypes.PacketState, err error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 661 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L661

Added line #L661 was not covered by tests
}

func (icp *IconProvider) QueryUnreceivedPackets(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 665 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L665

Added line #L665 was not covered by tests
}

func (icp *IconProvider) QueryUnreceivedAcknowledgements(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 669 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L669

Added line #L669 was not covered by tests
}

func (icp *IconProvider) QueryNextSeqRecv(ctx context.Context, height int64, channelid, portid string) (recvRes *chantypes.QueryNextSequenceReceiveResponse, err error) {
Expand Down Expand Up @@ -780,12 +791,12 @@
// ics 20 - transfer
// not required for icon
func (icp *IconProvider) QueryDenomTrace(ctx context.Context, denom string) (*transfertypes.DenomTrace, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 794 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L794

Added line #L794 was not covered by tests
}

// not required for icon
func (icp *IconProvider) QueryDenomTraces(ctx context.Context, offset, limit uint64, height int64) ([]transfertypes.DenomTrace, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

Check warning on line 799 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L799

Added line #L799 was not covered by tests
}

func (icp *IconProvider) QueryIconProof(ctx context.Context, height int64, keyHash []byte) ([]byte, error) {
Expand Down
4 changes: 4 additions & 0 deletions relayer/chains/wasm/event_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
return nil
}

if !eventFromIBCContractAddress(event.Attributes[0], contractAddress) {
return nil
}

Check warning on line 111 in relayer/chains/wasm/event_parser.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/event_parser.go#L109-L111

Added lines #L109 - L111 were not covered by tests

eventType := findEventType(event.Type)
attrs := event.Attributes[1:]
switch eventType {
Expand Down
33 changes: 31 additions & 2 deletions relayer/chains/wasm/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
NOT_IMPLEMENTED = " :: Not implemented for WASM"
)

func (ap *WasmProvider) QueryTx(ctx context.Context, hashHex string) (*provider.RelayerTxResponse, error) {

Check warning on line 42 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L42

Added line #L42 was not covered by tests
hash, err := hex.DecodeString(hashHex)
if err != nil {
return nil, err
Expand All @@ -61,7 +61,7 @@
}, nil

}
func (ap *WasmProvider) QueryTxs(ctx context.Context, page, limit int, events []string) ([]*provider.RelayerTxResponse, error) {

Check warning on line 64 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L64

Added line #L64 was not covered by tests
if len(events) == 0 {
return nil, errors.New("must declare at least one event to search")
}
Expand Down Expand Up @@ -115,7 +115,7 @@
return events
}

func (ap *WasmProvider) QueryLatestHeight(ctx context.Context) (int64, error) {

Check warning on line 118 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L118

Added line #L118 was not covered by tests

stat, err := ap.RPCClient.Status(ctx)
if err != nil {
Expand All @@ -127,7 +127,7 @@
}

// QueryIBCHeader returns the IBC compatible block header at a specific height.
func (ap *WasmProvider) QueryIBCHeader(ctx context.Context, h int64) (provider.IBCHeader, error) {

Check warning on line 130 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L130

Added line #L130 was not covered by tests
if h == 0 {
return nil, fmt.Errorf("No header at height 0")
}
Expand All @@ -136,31 +136,31 @@
return nil, err
}

return NewWasmIBCHeaderFromLightBlock(lightBlock), nil

Check warning on line 139 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L139

Added line #L139 was not covered by tests
}

func (ap *WasmProvider) QueryLightBlock(ctx context.Context, h int64) (provider.IBCHeader, *tmtypes.LightBlock, error) {
if h == 0 {
return nil, nil, fmt.Errorf("No header at height 0")
}
lightBlock, err := ap.LightProvider.LightBlock(ctx, h)
if err != nil {
return nil, nil, err
}

Check warning on line 149 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L142-L149

Added lines #L142 - L149 were not covered by tests

return NewWasmIBCHeaderFromLightBlock(lightBlock), lightBlock, nil

Check warning on line 151 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L151

Added line #L151 was not covered by tests
}

// query packet info for sequence
func (ap *WasmProvider) QuerySendPacket(ctx context.Context, srcChanID, srcPortID string, sequence uint64) (provider.PacketInfo, error) {
return provider.PacketInfo{}, fmt.Errorf("Not implemented for Wasm")

Check warning on line 156 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L155-L156

Added lines #L155 - L156 were not covered by tests
}
func (ap *WasmProvider) QueryRecvPacket(ctx context.Context, dstChanID, dstPortID string, sequence uint64) (provider.PacketInfo, error) {
return provider.PacketInfo{}, fmt.Errorf("Not implemented for Wasm")

Check warning on line 159 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L158-L159

Added lines #L158 - L159 were not covered by tests
}

// bank
func (ap *WasmProvider) QueryBalance(ctx context.Context, keyName string) (sdk.Coins, error) {

Check warning on line 163 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L163

Added line #L163 was not covered by tests
addr, err := ap.ShowAddress(keyName)
if err != nil {
return nil, err
Expand All @@ -169,7 +169,7 @@
return ap.QueryBalanceWithAddress(ctx, addr)
}

func (ap *WasmProvider) QueryBalanceWithAddress(ctx context.Context, address string) (sdk.Coins, error) {

Check warning on line 172 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L172

Added line #L172 was not covered by tests
qc := bankTypes.NewQueryClient(ap)
p := DefaultPageRequest()
coins := sdk.Coins{}
Expand Down Expand Up @@ -205,13 +205,13 @@
}

// staking
func (ap *WasmProvider) QueryUnbondingPeriod(context.Context) (time.Duration, error) {
// move to provider, panic

Check warning on line 209 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L208-L209

Added lines #L208 - L209 were not covered by tests
return 0, nil
}

// ics 02 - client
func (ap *WasmProvider) QueryClientState(ctx context.Context, height int64, clientid string) (ibcexported.ClientState, error) {

Check warning on line 214 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L214

Added line #L214 was not covered by tests
clientStateRes, err := ap.QueryClientStateResponse(ctx, height, clientid)
if err != nil {
return nil, err
Expand All @@ -225,7 +225,7 @@
}

// TODO: Check revision number
func (ap *WasmProvider) QueryClientStateResponse(ctx context.Context, height int64, srcClientId string) (*clienttypes.QueryClientStateResponse, error) {

Check warning on line 228 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L228

Added line #L228 was not covered by tests

clS, err := ap.QueryClientStateContract(ctx, srcClientId)
if err != nil {
Expand All @@ -237,7 +237,7 @@
}

storageKey := getStorageKeyFromPath(common.GetClientStateCommitmentKey(srcClientId))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 240 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L240

Added line #L240 was not covered by tests
if err != nil {
return nil, err
}
Expand All @@ -249,7 +249,7 @@
}, nil
}

func (ap *WasmProvider) QueryClientStateContract(ctx context.Context, clientId string) (*icon.ClientState, error) {

Check warning on line 252 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L252

Added line #L252 was not covered by tests
clientStateParam, err := types.NewClientState(clientId).Bytes()
if err != nil {
return nil, err
Expand All @@ -275,7 +275,7 @@
return iconClientState, nil
}

func (ap *WasmProvider) QueryConnectionContract(ctx context.Context, connId string) (*conntypes.ConnectionEnd, error) {

Check warning on line 278 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L278

Added line #L278 was not covered by tests
connStateParam, err := types.NewConnection(connId).Bytes()
if err != nil {
return nil, err
Expand All @@ -294,7 +294,7 @@
return &connS, nil
}

func (ap *WasmProvider) QueryChannelContract(ctx context.Context, portId, channelId string) (*chantypes.Channel, error) {

Check warning on line 297 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L297

Added line #L297 was not covered by tests
channelStateParam, err := types.NewChannel(portId, channelId).Bytes()
if err != nil {
return nil, err
Expand All @@ -312,7 +312,7 @@
return &channelS, nil
}

func (ap *WasmProvider) QueryClientConsensusState(ctx context.Context, chainHeight int64, clientid string, clientHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error) {

Check warning on line 315 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L315

Added line #L315 was not covered by tests
consensusStateParam, err := types.NewConsensusState(clientid, uint64(chainHeight)).Bytes()
consensusState, err := ap.QueryIBCHandlerContractProcessed(ctx, consensusStateParam)
if err != nil {
Expand All @@ -332,7 +332,7 @@
return clienttypes.NewQueryConsensusStateResponse(anyConsensusState, nil, clienttypes.NewHeight(0, uint64(chainHeight))), nil
}

func (ap *WasmProvider) QueryIBCHandlerContract(ctx context.Context, param wasmtypes.RawContractMessage) (*wasmtypes.QuerySmartContractStateResponse, error) {

Check warning on line 335 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L335

Added line #L335 was not covered by tests

return ap.QueryClient.SmartContractState(ctx, &wasmtypes.QuerySmartContractStateRequest{
Address: ap.PCfg.IbcHandlerAddress,
Expand All @@ -340,7 +340,7 @@
})
}

func (ap *WasmProvider) QueryIBCHandlerContractProcessed(ctx context.Context, param wasmtypes.RawContractMessage) ([]byte, error) {

Check warning on line 343 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L343

Added line #L343 was not covered by tests
res, err := ap.QueryIBCHandlerContract(ctx, param)
if err != nil {
return nil, err
Expand All @@ -348,15 +348,15 @@
return ProcessContractResponse(res)
}

func (ap *WasmProvider) QueryUpgradedClient(ctx context.Context, height int64) (*clienttypes.QueryClientStateResponse, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 352 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L351-L352

Added lines #L351 - L352 were not covered by tests
}

func (ap *WasmProvider) QueryUpgradedConsState(ctx context.Context, height int64) (*clienttypes.QueryConsensusStateResponse, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 356 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L355-L356

Added lines #L355 - L356 were not covered by tests
}

func (ap *WasmProvider) QueryConsensusState(ctx context.Context, height int64) (ibcexported.ConsensusState, int64, error) {

Check warning on line 359 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L359

Added line #L359 was not covered by tests

commit, err := ap.RPCClient.Commit(ctx, &height)
if err != nil {
Expand All @@ -381,7 +381,7 @@
return state, height, nil
}

func (ap *WasmProvider) getAllPorts(ctx context.Context) ([]string, error) {

Check warning on line 384 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L384

Added line #L384 was not covered by tests
param, err := types.NewGetAllPorts().Bytes()
if err != nil {
return make([]string, 0), err
Expand All @@ -399,7 +399,7 @@
return ports, nil
}

func (ap *WasmProvider) getNextSequence(ctx context.Context, methodName string) (int, error) {

Check warning on line 402 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L402

Added line #L402 was not covered by tests
switch methodName {
case MethodGetNextClientSequence:
param, err := types.NewNextClientSequence().Bytes()
Expand Down Expand Up @@ -441,7 +441,7 @@
}
}

func (ap *WasmProvider) QueryClients(ctx context.Context) (clienttypes.IdentifiedClientStates, error) {

Check warning on line 444 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L444

Added line #L444 was not covered by tests

seq, err := ap.getNextSequence(ctx, MethodGetNextClientSequence)
if err != nil {
Expand All @@ -466,7 +466,7 @@
}

// ics 03 - connection
func (ap *WasmProvider) QueryConnection(ctx context.Context, height int64, connectionid string) (*conntypes.QueryConnectionResponse, error) {

Check warning on line 469 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L469

Added line #L469 was not covered by tests
connectionStateParams, err := types.NewConnection(connectionid).Bytes()
if err != nil {
return nil, err
Expand All @@ -484,12 +484,12 @@
}

storageKey := getStorageKeyFromPath(common.GetConnectionCommitmentKey(connectionid))
connProof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 487 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L487

Added line #L487 was not covered by tests

return conntypes.NewQueryConnectionResponse(conn, connProof, clienttypes.NewHeight(0, uint64(height))), nil
}

func (ap *WasmProvider) QueryWasmProof(ctx context.Context, storageKey []byte, height int64) ([]byte, error) {

Check warning on line 492 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L492

Added line #L492 was not covered by tests
ibcAddr, err := sdk.AccAddressFromBech32(ap.PCfg.IbcHandlerAddress)
if err != nil {
return nil, err
Expand Down Expand Up @@ -533,7 +533,7 @@

}

func (ap *WasmProvider) QueryConnections(ctx context.Context) (conns []*conntypes.IdentifiedConnection, err error) {

Check warning on line 536 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L536

Added line #L536 was not covered by tests

seq, err := ap.getNextSequence(ctx, MethodGetNextConnectionSequence)
if err != nil {
Expand All @@ -552,7 +552,7 @@
}

// Only return open conenctions
if conn.State == conntypes.OPEN {

Check warning on line 555 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L555

Added line #L555 was not covered by tests
identifiedConn := conntypes.IdentifiedConnection{
Id: connectionId,
ClientId: conn.ClientId,
Expand All @@ -568,8 +568,8 @@
return conns, nil
}

func (ap *WasmProvider) QueryConnectionsUsingClient(ctx context.Context, height int64, clientid string) (*conntypes.QueryConnectionsResponse, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 572 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L571-L572

Added lines #L571 - L572 were not covered by tests
}

func (ap *WasmProvider) GenerateConnHandshakeProof(ctx context.Context, height int64, clientId, connId string) (clientState ibcexported.ClientState,
Expand All @@ -588,14 +588,14 @@
}

connStorageKey := getStorageKeyFromPath(common.GetConnectionCommitmentKey(connId))
proofConnBytes, err := ap.QueryWasmProof(ctx, connStorageKey, height)

Check warning on line 591 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L591

Added line #L591 was not covered by tests
if err != nil {
return nil, nil, nil, nil, nil, err

}

consStorageKey := getStorageKeyFromPath(common.GetConsensusStateCommitmentKey(clientId, big.NewInt(0), big.NewInt(height)))
proofConsensusBytes, err := ap.QueryWasmProof(ctx, consStorageKey, height)

Check warning on line 598 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L598

Added line #L598 was not covered by tests
if err != nil {
return nil, nil, nil, nil, nil, err
}
Expand All @@ -603,7 +603,7 @@
}

// ics 04 - channel
func (ap *WasmProvider) QueryChannel(ctx context.Context, height int64, channelid, portid string) (chanRes *chantypes.QueryChannelResponse, err error) {

Check warning on line 606 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L606

Added line #L606 was not covered by tests
channelParams, err := types.NewChannel(portid, channelid).Bytes()
if err != nil {
return nil, err
Expand All @@ -624,16 +624,16 @@
}

storageKey := getStorageKeyFromPath(common.GetChannelCommitmentKey(portid, channelid))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 627 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L627

Added line #L627 was not covered by tests

return chantypes.NewQueryChannelResponse(channelS, proof, clienttypes.NewHeight(0, uint64(height))), nil
}

func (ap *WasmProvider) QueryChannelClient(ctx context.Context, height int64, channelid, portid string) (*clienttypes.IdentifiedClientState, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 633 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L632-L633

Added lines #L632 - L633 were not covered by tests
}

func (ap *WasmProvider) QueryConnectionChannels(ctx context.Context, height int64, connectionid string) ([]*chantypes.IdentifiedChannel, error) {

Check warning on line 636 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L636

Added line #L636 was not covered by tests
allChannel, err := ap.QueryChannels(ctx)
if err != nil {
return nil, fmt.Errorf("error querying Channels %v", err)
Expand All @@ -647,7 +647,7 @@
return identifiedChannels, nil
}

func (ap *WasmProvider) QueryChannels(ctx context.Context) ([]*chantypes.IdentifiedChannel, error) {

Check warning on line 650 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L650

Added line #L650 was not covered by tests
nextSeq, err := ap.getNextSequence(ctx, MethodGetNextChannelSequence)
if err != nil {
return nil, err
Expand All @@ -671,7 +671,7 @@
}

// check if the channel is open
if channel.State == chantypes.OPEN {

Check warning on line 674 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L674

Added line #L674 was not covered by tests
identifiedChannel := chantypes.IdentifiedChannel{
State: channel.State,
Ordering: channel.Ordering,
Expand All @@ -689,23 +689,23 @@
return channels, nil
}

func (ap *WasmProvider) QueryPacketCommitments(ctx context.Context, height uint64, channelid, portid string) (commitments *chantypes.QueryPacketCommitmentsResponse, err error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 693 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L692-L693

Added lines #L692 - L693 were not covered by tests
}

func (ap *WasmProvider) QueryPacketAcknowledgements(ctx context.Context, height uint64, channelid, portid string) (acknowledgements []*chantypes.PacketState, err error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 697 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L696-L697

Added lines #L696 - L697 were not covered by tests
}

func (ap *WasmProvider) QueryUnreceivedPackets(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 701 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L700-L701

Added lines #L700 - L701 were not covered by tests
}

func (ap *WasmProvider) QueryUnreceivedAcknowledgements(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 705 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L704-L705

Added lines #L704 - L705 were not covered by tests
}

func (ap *WasmProvider) QueryNextSeqRecv(ctx context.Context, height int64, channelid, portid string) (recvRes *chantypes.QueryNextSequenceReceiveResponse, err error) {

Check warning on line 708 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L708

Added line #L708 was not covered by tests
nextSeqRecvParams, err := types.NewNextSequenceReceive(portid, channelid).Bytes()
if err != nil {
return nil, err
Expand All @@ -715,7 +715,7 @@
return nil, err
}

proof, err := ap.QueryWasmProof(ctx, common.MustHexStrToBytes(STORAGEKEY__NextSequenceReceive), height)

Check warning on line 718 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L718

Added line #L718 was not covered by tests
if err != nil {
return nil, err
}
Expand All @@ -727,7 +727,7 @@
}, nil
}

func (ap *WasmProvider) QueryPacketCommitment(ctx context.Context, height int64, channelid, portid string, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error) {

Check warning on line 730 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L730

Added line #L730 was not covered by tests
pktCommitmentParams, err := types.NewPacketCommitment(portid, channelid, seq).Bytes()
if err != nil {
return nil, err
Expand All @@ -737,7 +737,7 @@
return nil, err
}
storageKey := getStorageKeyFromPath(common.GetPacketCommitmentKey(portid, channelid, big.NewInt(int64(seq))))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 740 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L740

Added line #L740 was not covered by tests

if err != nil {
return nil, err
Expand All @@ -750,7 +750,7 @@

}

func (ap *WasmProvider) QueryPacketAcknowledgement(ctx context.Context, height int64, channelid, portid string, seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error) {

Check warning on line 753 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L753

Added line #L753 was not covered by tests
pktAcknowledgementParams, err := types.NewPacketAcknowledgementCommitment(portid, channelid, seq).Bytes()
if err != nil {
return nil, err
Expand All @@ -760,7 +760,7 @@
return nil, err
}
storageKey := getStorageKeyFromPath(common.GetPacketAcknowledgementCommitmentKey(portid, channelid, big.NewInt(int64(seq))))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 763 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L763

Added line #L763 was not covered by tests

return &chantypes.QueryPacketAcknowledgementResponse{
Acknowledgement: pktAcknowledgement.Data.Bytes(),
Expand All @@ -769,11 +769,11 @@
}, nil
}

func (ap *WasmProvider) QueryPacketReceipt(ctx context.Context, height int64, channelid, portid string, seq uint64) (recRes *chantypes.QueryPacketReceiptResponse, err error) {

Check warning on line 772 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L772

Added line #L772 was not covered by tests

// getting proof from commitment map in contract
storageKey := getStorageKeyFromPath(common.GetPacketReceiptCommitmentKey(portid, channelid, big.NewInt(int64(seq))))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 776 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L776

Added line #L776 was not covered by tests
if err != nil {
return nil, err
}
Expand All @@ -795,7 +795,7 @@
}, nil
}

func (ap *WasmProvider) GetCommitmentPrefixFromContract(ctx context.Context) ([]byte, error) {

Check warning on line 798 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L798

Added line #L798 was not covered by tests

pktCommitmentParams, err := types.NewCommitmentPrefix().Bytes()
if err != nil {
Expand All @@ -806,9 +806,38 @@
}

// ics 20 - transfer
func (ap *WasmProvider) QueryDenomTrace(ctx context.Context, denom string) (*transfertypes.DenomTrace, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))
transfers, err := transfertypes.NewQueryClient(ap).DenomTrace(ctx,
&transfertypes.QueryDenomTraceRequest{
Hash: denom,
})
if err != nil {
return nil, err
}
return transfers.DenomTrace, nil

Check warning on line 817 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L809-L817

Added lines #L809 - L817 were not covered by tests
}
func (ap *WasmProvider) QueryDenomTraces(ctx context.Context, offset, limit uint64, height int64) ([]transfertypes.DenomTrace, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))
qc := transfertypes.NewQueryClient(ap)
p := DefaultPageRequest()
transfers := []transfertypes.DenomTrace{}
for {
res, err := qc.DenomTraces(ctx,
&transfertypes.QueryDenomTracesRequest{
Pagination: p,
})

if err != nil || res == nil {
return nil, err
}

Check warning on line 831 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L819-L831

Added lines #L819 - L831 were not covered by tests

transfers = append(transfers, res.DenomTraces...)
next := res.GetPagination().GetNextKey()
if len(next) == 0 {
break

Check warning on line 836 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L833-L836

Added lines #L833 - L836 were not covered by tests
}

time.Sleep(PaginationDelay)
p.Key = next

Check warning on line 840 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L839-L840

Added lines #L839 - L840 were not covered by tests
}
return transfers, nil

Check warning on line 842 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L842

Added line #L842 was not covered by tests
}
File renamed without changes.
3 changes: 2 additions & 1 deletion relayer/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
sdk "github.com/cosmos/cosmos-sdk/types"
chantypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/cosmos/relayer/v2/relayer/common"
"github.com/cosmos/relayer/v2/relayer/provider"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -234,7 +235,7 @@
return nil, err
}

if showDenoms {
if showDenoms || chain.ChainProvider.Type() == common.IconModule {

Check warning on line 238 in relayer/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/query.go#L238

Added line #L238 was not covered by tests
return coins, nil
}

Expand Down
Loading