Skip to content

Commit

Permalink
update key path from string to bytes for wasmbinding (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
antstalepresh authored Jun 19, 2024
1 parent da75633 commit 16fffa0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions wasmbinding/bindings/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type VerifyMembershipQuery struct {
Proof []byte `json:"proof"`
Value []byte `json:"value"`
PathPrefix string `json:"path_prefix"`
PathKey string `json:"path_key"`
PathKey []byte `json:"path_key"`
}

type VerifyNonMembershipQuery struct {
Expand All @@ -29,7 +29,7 @@ type VerifyNonMembershipQuery struct {
RevisionHeight uint64 `json:"revision_height"`
Proof []byte `json:"proof"`
PathPrefix string `json:"path_prefix"`
PathKey string `json:"path_key"`
PathKey []byte `json:"path_key"`
}

type IbcVerifyResponse struct{}
Expand Down Expand Up @@ -119,7 +119,7 @@ func HandleIBCQuery(ctx sdk.Context, keeper ibckeeper.Keeper, ibcStoreKey *store
}

height := clienttypes.NewHeight(q.VerifyMembership.RevisionNumber, q.VerifyMembership.RevisionHeight)
consState, merklePath, err := getConsStateAndMerklePath(keeper, clientState, clientStore, height, q.VerifyMembership.PathPrefix, q.VerifyMembership.PathKey)
consState, merklePath, err := getConsStateAndMerklePath(keeper, clientState, clientStore, height, q.VerifyMembership.PathPrefix, string(q.VerifyMembership.PathKey))
if err != nil {
return err
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func HandleIBCQuery(ctx sdk.Context, keeper ibckeeper.Keeper, ibcStoreKey *store
}

height := clienttypes.NewHeight(q.VerifyNonMembership.RevisionNumber, q.VerifyNonMembership.RevisionHeight)
consState, merklePath, err := getConsStateAndMerklePath(keeper, clientState, clientStore, height, q.VerifyMembership.PathPrefix, q.VerifyMembership.PathKey)
consState, merklePath, err := getConsStateAndMerklePath(keeper, clientState, clientStore, height, q.VerifyMembership.PathPrefix, string(q.VerifyMembership.PathKey))
if err != nil {
return err
}
Expand Down
11 changes: 6 additions & 5 deletions wasmbinding/test/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestQueryExchangeRates(t *testing.T) {
})
require.NoError(t, err)

res, err = querier(ctx, bz)
_, err = querier(ctx, bz)
require.NoError(t, err)

queryParams = wasm.ExchangeRateQueryParams{
Expand Down Expand Up @@ -118,6 +118,7 @@ func TestSupply(t *testing.T) {
var x banktypes.QuerySupplyOfResponse

res, err := querier(ctx, bz)
require.NoError(t, err)

err = json.Unmarshal(res, &x)
require.NoError(t, err)
Expand All @@ -137,14 +138,14 @@ func TestVerifyMembership(t *testing.T) {
Proof: []byte{},
Value: []byte{},
PathPrefix: "ibc",
PathKey: "connections/connection-0",
PathKey: []byte("connections/connection-0"),
},
}

bz, err := json.Marshal(queryMsg)
require.NoError(t, err)

bz, err = app.WasmKeeper.QuerySmart(ctx, contractAddr, bz)
_, err = app.WasmKeeper.QuerySmart(ctx, contractAddr, bz)
require.Error(t, err)
}

Expand All @@ -161,13 +162,13 @@ func TestVerifyNonMembership(t *testing.T) {
RevisionHeight: 0,
Proof: []byte{},
PathPrefix: "ibc",
PathKey: "connections/connection-0",
PathKey: []byte("connections/connection-0"),
},
}

bz, err := json.Marshal(queryMsg)
require.NoError(t, err)

bz, err = app.WasmKeeper.QuerySmart(ctx, contractAddr, bz)
_, err = app.WasmKeeper.QuerySmart(ctx, contractAddr, bz)
require.Error(t, err)
}

0 comments on commit 16fffa0

Please sign in to comment.