Skip to content
Draft
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
8 changes: 8 additions & 0 deletions e2e/tests/100-atomic-swap/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions modules/apps/100-atomic-swap/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
32 changes: 0 additions & 32 deletions modules/apps/100-atomic-swap/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// }
16 changes: 9 additions & 7 deletions proto/ibc/applications/interchain_swap/v1/packet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 28 additions & 0 deletions proto/ibc/applications/interchain_swap/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down