Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9836f3

Browse files
committed
fix bugs, add testcodes
1 parent ca62748 commit e9836f3

26 files changed

+201
-875
lines changed

app/app.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,11 @@ func (app *LiquidityApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.
583583
}
584584
}
585585

586-
587586
// RegisterTxService implements the Application.RegisterTxService method.
588587
func (app *LiquidityApp) RegisterTxService(clientCtx client.Context) {
589588
authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry)
590589
}
591590

592-
593591
// RegisterSwaggerAPI registers swagger route with API Server
594592
func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
595593
statikFS, err := fs.New()

app/export.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ func (app *LiquidityApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd
166166
log.Fatal(err)
167167
}
168168

169-
170169
/* Handle slashing state. */
171170

172171
// reset start height on signing infos

app/test_helpers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,6 @@ func TestSwapPool(t *testing.T, simapp *LiquidityApp, ctx sdk.Context, offerCoin
763763
return batchPoolSwapMsgList, batch
764764
}
765765

766-
767766
func GetSwapMsg(t *testing.T, simapp *LiquidityApp, ctx sdk.Context, offerCoinList []sdk.Coin, orderPrices []sdk.Dec,
768767
addrs []sdk.AccAddress, poolId uint64) []*types.MsgSwap {
769768
if len(offerCoinList) != len(orderPrices) || len(orderPrices) != len(addrs) {
@@ -789,7 +788,7 @@ func GetSwapMsg(t *testing.T, simapp *LiquidityApp, ctx sdk.Context, offerCoinLi
789788
require.True(t, false)
790789
}
791790

792-
msgList = append(msgList,types.NewMsgSwap(addrs[i], poolId, types.DefaultPoolTypeIndex, types.DefaultSwapType, offerCoinList[i], demandCoinDenom, orderPrices[i]))
791+
msgList = append(msgList, types.NewMsgSwap(addrs[i], poolId, types.DefaultPoolTypeIndex, types.DefaultSwapType, offerCoinList[i], demandCoinDenom, orderPrices[i]))
793792
}
794793
return msgList
795794
}

proto/genesis.proto

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,99 +2,25 @@ syntax = "proto3";
22
package tendermint.liquidity;
33

44
import "liquidity.proto";
5-
import "tx.proto";
65
import "gogoproto/gogo.proto";
7-
import "cosmos_proto/coin.proto";
86

97
option go_package = "github.com/tendermint/liquidity/types";
108

11-
129
message LiquidityPoolRecord {
1310
LiquidityPool liquidity_pool = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pool\""];
1411
LiquidityPoolMetaData liquidity_pool_meta_data = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pool_meta_data\""];
1512
LiquidityPoolBatch liquidity_pool_batch = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pool_batch\""];
16-
// TODO: msg in BatchPool*Msg pointer issue, try and delete when unnecessary
17-
repeated BatchPoolSwapMsgRecord batch_pool_swap_msg_records = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_swap_msg_records\""];
18-
repeated BatchPoolDepositMsg batch_pool_deposit_msgs = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_deposit_msgs\""];
19-
repeated BatchPoolWithdrawMsg batch_pool_withdraw_msgs = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_withdraw_msgs\""];
20-
repeated BatchPoolSwapMsg batch_pool_swap_msgs = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_swap_msgs\""];
21-
// TODO: invariant check balance of escrow module acc, reserveAcc
13+
repeated BatchPoolDepositMsg batch_pool_deposit_msgs = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_deposit_msgs\""];
14+
repeated BatchPoolWithdrawMsg batch_pool_withdraw_msgs = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_withdraw_msgs\""];
15+
repeated BatchPoolSwapMsg batch_pool_swap_msgs = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_swap_msgs\""];
2216
}
2317

24-
2518
// GenesisState defines the liquidity module's genesis state.
2619
message GenesisState {
2720
option (gogoproto.equal) = false;
2821
option (gogoproto.goproto_getters) = false;
2922

3023
// params defines all the parameters of related to liquidity.
3124
Params params = 1 [(gogoproto.nullable) = false];
32-
33-
3425
repeated LiquidityPoolRecord liquidity_pool_records = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pools\""];
3526
}
36-
37-
//
38-
//// GenesisState defines the liquidity module's genesis state.
39-
//message GenesisState {
40-
// option (gogoproto.equal) = false;
41-
// option (gogoproto.goproto_getters) = false;
42-
//
43-
// // params defines all the parameters of related to liquidity.
44-
// Params params = 1 [(gogoproto.nullable) = false];
45-
//
46-
// repeated LiquidityPool liquidity_pools = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pools\""];
47-
//
48-
// repeated LiquidityPoolMetaData liquidity_pools_meta_data = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pools_meta_data\""];
49-
//
50-
// repeated LiquidityPoolBatch liquidity_pool_batches = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pool_batches\""];
51-
//
52-
// repeated BatchPoolDepositMsg batch_pool_deposit_msgs = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_deposit_msgs\""];
53-
//
54-
// repeated BatchPoolWithdrawMsg batch_pool_withdraw_msgs = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_withdraw_msgs\""];
55-
//
56-
// repeated BatchPoolSwapMsg batch_pool_swap_msgs = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_swap_msgs\""];
57-
//
58-
// repeated BatchPoolSwapMsgRecord batch_pool_swap_msg_records = 8 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"batch_pool_swap_msg_records\""];
59-
//
60-
// repeated QueryLiquidityPoolResponse liquidity_pool_records = 9 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pool_records\""];
61-
//
62-
// // TODO: invariant check balance of escrow module acc, reserveAcc
63-
//
64-
//}
65-
//
66-
//message BatchPoolDepositMsgRecord {
67-
// int64 msg_height = 1 [(gogoproto.moretags) = "yaml:\"msg_height\""];
68-
// uint64 msg_index = 2 [(gogoproto.moretags) = "yaml:\"msg_index\""];
69-
// bool executed = 3 [(gogoproto.moretags) = "yaml:\"executed\""];
70-
// bool succeed = 4 [(gogoproto.moretags) = "yaml:\"succeed\""];
71-
// bool to_delete = 5 [(gogoproto.moretags) = "yaml:\"to_delete\""];
72-
// MsgDepositToLiquidityPool Msg = 6 [(gogoproto.moretags) = "yaml:\"msg\"", (gogoproto.nullable) = false];
73-
//}
74-
//
75-
//message BatchPoolWithdrawMsgRecord {
76-
// int64 msg_height = 1 [(gogoproto.moretags) = "yaml:\"msg_height\""];
77-
// uint64 msg_index = 2 [(gogoproto.moretags) = "yaml:\"msg_index\""];
78-
// bool executed = 3 [(gogoproto.moretags) = "yaml:\"executed\""];
79-
// bool succeed = 4 [(gogoproto.moretags) = "yaml:\"succeed\""];
80-
// bool to_delete = 5 [(gogoproto.moretags) = "yaml:\"to_delete\""];
81-
// MsgWithdrawFromLiquidityPool msg = 6 [(gogoproto.moretags) = "yaml:\"msg\"", (gogoproto.nullable) = false];
82-
//}
83-
//
84-
message BatchPoolSwapMsgRecord {
85-
int64 msg_height = 1 [(gogoproto.moretags) = "yaml:\"msg_height\""];
86-
uint64 msg_index = 2 [(gogoproto.moretags) = "yaml:\"msg_index\""];
87-
bool executed = 3 [(gogoproto.moretags) = "yaml:\"executed\""];
88-
bool succeed = 4 [(gogoproto.moretags) = "yaml:\"succeed\""];
89-
bool to_delete = 5 [(gogoproto.moretags) = "yaml:\"to_delete\""];
90-
int64 order_expiry_height = 6 [(gogoproto.moretags) = "yaml:\"order_expiry_height\""];
91-
cosmos.base.v1beta1.Coin exchanged_offer_coin = 7 [
92-
(gogoproto.nullable) = false,
93-
(gogoproto.moretags) = "yaml:\"exchanged_offer_coin\""
94-
];
95-
cosmos.base.v1beta1.Coin remaining_offer_coin = 8 [
96-
(gogoproto.nullable) = false,
97-
(gogoproto.moretags) = "yaml:\"remaining_offer_coin\""
98-
];
99-
MsgSwap msg = 9 [(gogoproto.moretags) = "yaml:\"msg\"", (gogoproto.nullable) = false];
100-
}

x/liquidity/client/cli/cli_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package cli_test
2+
23
//
34
//import (
45
// "testing"

x/liquidity/client/cli/query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ $ %s query liquidity liquidity-pool 1
7171

7272
_, err = queryClient.LiquidityPool(
7373
context.Background(),
74-
&types.QueryLiquidityPoolRequest{PoolId:poolId},
74+
&types.QueryLiquidityPoolRequest{PoolId: poolId},
7575
)
7676
if err != nil {
7777
return fmt.Errorf("failed to fetch poolId %d: %s", poolId, err)
7878
}
7979

8080
//params := types.NewQueryLiquidityPoolParams(poolId)
81-
params := &types.QueryLiquidityPoolRequest{PoolId:poolId}
81+
params := &types.QueryLiquidityPoolRequest{PoolId: poolId}
8282
res, err = queryClient.LiquidityPool(context.Background(), params)
8383
if err != nil {
8484
return err

x/liquidity/client/cli/tx.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@ the number of deposit coins must be two in the pool-type-index 1
8282
return err
8383
}
8484

85-
8685
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
8786
},
8887
}
8988
flags.AddTxFlagsToCmd(cmd)
9089

9190
return cmd
92-
}
91+
}

x/liquidity/client/rest/tx.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
// TODO: Plans to increase completeness on Milestone 2
1515

16-
1716
func registerTxRoutes(clientCtx client.Context, r *mux.Router) {
1817
//// create liquidityPool
1918
//r.HandleFunc(fmt.Sprintf("/liquidity/pool"), newLiquidityPoolHandlerFn(clientCtx)).Methods("POST")

x/liquidity/genesis.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) {
1414
for _, record := range data.LiquidityPoolRecords {
1515
k.SetLiquidityPoolRecord(ctx, &record)
1616
}
17+
// TODO: verify GetNextBatchIndexWithUpdate, GetNextLiquidityPoolIdWithUpdate
1718
}
1819

1920
// ExportGenesis returns a GenesisState for a given context and keeper.

x/liquidity/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
3535
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
3636
}
3737
}
38-
}
38+
}

0 commit comments

Comments
 (0)