diff --git a/e2e/tests/100-atomic-swap/base_test.go b/e2e/tests/100-atomic-swap/base_test.go index 0961451f..724799ed 100644 --- a/e2e/tests/100-atomic-swap/base_test.go +++ b/e2e/tests/100-atomic-swap/base_test.go @@ -98,6 +98,14 @@ func (s *AtomicSwapTestSuite) TestAtomicSwap_HappyPath() { s.Require().NoError(err) s.Require().Equal(len(res.Orders), 1) + res, err = s.QueryAtomicswapByOrders(ctx, chainA, types.OrderType_SellToBuy) + s.Require().NoError(err) + s.Require().Equal(len(res.Orders), 1) + + res, err = s.QueryAtomicswapByOrders(ctx, chainB, types.OrderType_BuyToSell) + s.Require().NoError(err) + s.Require().Equal(len(res.Orders), 1) + res, err = s.QuerySubmittedAtomicswap(ctx, chainA, makerAddressOnChainA) s.Require().NoError(err) s.Require().Equal(len(res.Orders), 1) diff --git a/modules/apps/100-atomic-swap/keeper/grpc_query.go b/modules/apps/100-atomic-swap/keeper/grpc_query.go index aabe302f..7ca3567f 100644 --- a/modules/apps/100-atomic-swap/keeper/grpc_query.go +++ b/modules/apps/100-atomic-swap/keeper/grpc_query.go @@ -42,8 +42,6 @@ func (q Keeper) GetAllOrdersByType(ctx context.Context, request *types.QueryOrde if (acc != nil && request.OrderType == types.OrderType_SellToBuy) || (acc == nil && request.OrderType == types.OrderType_BuyToSell) { orders = append(orders, &order) - } else { - return types.ErrInvalidCodec } return nil }) diff --git a/modules/apps/100-atomic-swap/keeper/keeper.go b/modules/apps/100-atomic-swap/keeper/keeper.go index 1cc85243..f8dd818a 100644 --- a/modules/apps/100-atomic-swap/keeper/keeper.go +++ b/modules/apps/100-atomic-swap/keeper/keeper.go @@ -132,35 +132,3 @@ func (k Keeper) SetAtomicOrder(ctx sdk.Context, order types.Order) { store.Set([]byte(order.Id), bz) } -// // IterateAtomicOrders iterates over the limit orders in the store -// // and performs a callback function. -// func (k Keeper) IterateAtomicOrders(ctx sdk.Context, req *types.QueryOrdersRequest, cb func(order types.Order) bool) { -// store := ctx.KVStore(k.storeKey) -// iterator := sdk.KVStorePrefixIterator(store, types.OTCOrderBookKey) - -// defer iterator.Close() -// for ; iterator.Valid(); iterator.Next() { -// order := k.MustUnmarshalOrder(iterator.Value()) -// if cb(order) { -// break -// } -// } -// } - -// // GetAllAtomicOrders returns the information for all the limit orders. -// func (k Keeper) GetAllAtomicOrders(ctx sdk.Context, req *types.QueryOrdersRequest) (*types.QueryOrdersResponse, error) { - -// orderStore := ctx.KVStore(k.storeKey) -// iterator := sdk.KVStorePrefixIterator(orderStore, types.OTCOrderBookKey) -// var orders []*types.Order -// pageRes, err := query.Paginate(orderStore, req.Pagination, func(key, value []byte) error { -// order := k.MustUnmarshalOrder(iterator.Value()) -// orders = append(orders, &order) -// return nil -// }) -// if err != nil { -// return nil, status.Errorf(codes.Internal, "paginate: %v", err) -// } - -// return &types.QueryOrdersResponse{Orders: orders, Pagination: pageRes}, err -// } diff --git a/proto/ibc/applications/interchain_swap/v1/packet.proto b/proto/ibc/applications/interchain_swap/v1/packet.proto index 57039540..3dba6e68 100644 --- a/proto/ibc/applications/interchain_swap/v1/packet.proto +++ b/proto/ibc/applications/interchain_swap/v1/packet.proto @@ -16,13 +16,15 @@ enum SwapMessageType { TYPE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNSPECIFIED"]; TYPE_MAKE_POOL = 1 [(gogoproto.enumvalue_customname) = "MAKE_POOL"]; - TYPE_TAKE_POOL = 2 [(gogoproto.enumvalue_customname) = "TAKE_POOL"]; - TYPE_SINGLE_DEPOSIT = 3 [(gogoproto.enumvalue_customname) = "SINGLE_DEPOSIT"]; - TYPE_MAKE_MULTI_DEPOSIT = 4 [(gogoproto.enumvalue_customname) = "MAKE_MULTI_DEPOSIT"]; - TYPE_TAKE_MULTI_DEPOSIT = 5 [(gogoproto.enumvalue_customname) = "TAKE_MULTI_DEPOSIT"]; - TYPE_MULTI_WITHDRAW = 7 [(gogoproto.enumvalue_customname) = "MULTI_WITHDRAW"]; - TYPE_LEFT_SWAP = 8 [(gogoproto.enumvalue_customname) = "LEFT_SWAP"]; - TYPE_RIGHT_SWAP = 9 [(gogoproto.enumvalue_customname) = "RIGHT_SWAP"]; + TYPE_CANCEL_POOL = 2 [(gogoproto.enumvalue_customname) = "CANCEL_POOL"]; + TYPE_TAKE_POOL = 3 [(gogoproto.enumvalue_customname) = "TAKE_POOL"]; + TYPE_SINGLE_DEPOSIT = 4 [(gogoproto.enumvalue_customname) = "SINGLE_DEPOSIT"]; + TYPE_MAKE_MULTI_DEPOSIT = 5 [(gogoproto.enumvalue_customname) = "MAKE_MULTI_DEPOSIT"]; + TYPE_CANCEL_MULTI_DEPOSIT = 6 [(gogoproto.enumvalue_customname) = "CANCEL__MULTI_DEPOSIT"]; + TYPE_TAKE_MULTI_DEPOSIT = 7 [(gogoproto.enumvalue_customname) = "TAKE_MULTI_DEPOSIT"]; + TYPE_MULTI_WITHDRAW = 8 [(gogoproto.enumvalue_customname) = "MULTI_WITHDRAW"]; + TYPE_LEFT_SWAP = 9 [(gogoproto.enumvalue_customname) = "LEFT_SWAP"]; + TYPE_RIGHT_SWAP = 10 [(gogoproto.enumvalue_customname) = "RIGHT_SWAP"]; } message StateChange { diff --git a/proto/ibc/applications/interchain_swap/v1/tx.proto b/proto/ibc/applications/interchain_swap/v1/tx.proto index fe948ac3..00d131c8 100644 --- a/proto/ibc/applications/interchain_swap/v1/tx.proto +++ b/proto/ibc/applications/interchain_swap/v1/tx.proto @@ -17,10 +17,12 @@ import "ibc/applications/interchain_swap/v1/market.proto"; // Msg defines the Msg service. service Msg { rpc MakePool (MsgMakePoolRequest) returns (MsgMakePoolResponse); + rpc CancelPool (MsgTakePoolRequest) returns (MsgTakePoolResponse); rpc TakePool (MsgTakePoolRequest) returns (MsgTakePoolResponse); rpc SingleAssetDeposit (MsgSingleAssetDepositRequest ) returns (MsgSingleAssetDepositResponse ); rpc MakeMultiAssetDeposit (MsgMakeMultiAssetDepositRequest ) returns (MsgMultiAssetDepositResponse ); + rpc CancelMultiAssetDeposit (MsgCancelMultiAssetDepositRequest ) returns (MsgCancelMultiAssetDepositResponse ); rpc TakeMultiAssetDeposit (MsgTakeMultiAssetDepositRequest ) returns (MsgMultiAssetDepositResponse ); rpc MultiAssetWithdraw (MsgMultiAssetWithdrawRequest ) returns (MsgMultiAssetWithdrawResponse ); rpc Swap (MsgSwapRequest ) returns (MsgSwapResponse ); @@ -40,6 +42,16 @@ message MsgMakePoolResponse { string poolId = 1; } +// cancel pool +message MsgCancelPoolRequest { + string creator = 1; + string poolId = 2; + ibc.core.client.v1.Height timeoutHeight = 3 [(gogoproto.moretags) = "yaml:\"timeout_height\""]; + uint64 timeoutTimeStamp = 4; +} +message MsgCancelPoolResponse { + string poolId = 1; +} message MsgTakePoolRequest { string creator = 1; @@ -73,6 +85,22 @@ message MsgMakeMultiAssetDepositRequest { uint64 timeoutTimeStamp = 4; } +// cancel multi-asset deposit order + +// make multi-asset deposit order +message MsgCancelMultiAssetDepositRequest { + string sender = 1; + string poolId = 2; + uint64 orderId = 3; + ibc.core.client.v1.Height timeoutHeight = 4; + uint64 timeoutTimeStamp = 5; +} + +message MsgCancelMultiAssetDepositResponse { + string poolId = 1; +} + + // make multi-asset deposit order message MsgTakeMultiAssetDepositRequest { string sender = 1;