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

Skip to content

Commit e00a80d

Browse files
committed
wip add export
1 parent f9a51fe commit e00a80d

19 files changed

+1836
-185
lines changed

app/test_helpers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ func TestWithdrawPool(t *testing.T, simapp *LiquidityApp, ctx sdk.Context, poolC
662662
iterNum := len(addrs)
663663
for i := 0; i < iterNum; i++ {
664664
balancePoolCoin := simapp.BankKeeper.GetBalance(ctx, addrs[i], pool.PoolCoinDenom)
665+
fmt.Println(balancePoolCoin, poolCoinAmt)
665666
require.True(t, balancePoolCoin.Amount.GTE(poolCoinAmt))
666667

667668
withdrawCoin := sdk.NewCoin(pool.PoolCoinDenom, poolCoinAmt)
@@ -694,6 +695,7 @@ func TestWithdrawPool(t *testing.T, simapp *LiquidityApp, ctx sdk.Context, poolC
694695

695696
// verify burned pool coin
696697
poolCoinAfter := simapp.LiquidityKeeper.GetPoolCoinTotalSupply(ctx, pool)
698+
fmt.Println(poolCoinAfter, poolCoinBefore)
697699
require.True(t, poolCoinAfter.LT(poolCoinBefore))
698700

699701
for i := 0; i < iterNum; i++ {

client/docs/statik/statik.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/genesis.proto

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,99 @@ syntax = "proto3";
22
package tendermint.liquidity;
33

44
import "liquidity.proto";
5+
import "tx.proto";
56
import "gogoproto/gogo.proto";
7+
import "cosmos_proto/coin.proto";
68

79
option go_package = "github.com/tendermint/liquidity/types";
810

9-
// GenesisState defines the nft module's genesis state.
11+
12+
message LiquidityPoolRecord {
13+
LiquidityPool liquidity_pool = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pool\""];
14+
LiquidityPoolMetaData liquidity_pool_meta_data = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pool_meta_data\""];
15+
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
22+
}
23+
24+
25+
// GenesisState defines the liquidity module's genesis state.
1026
message GenesisState {
27+
option (gogoproto.equal) = false;
28+
option (gogoproto.goproto_getters) = false;
29+
30+
// params defines all the parameters of related to liquidity.
1131
Params params = 1 [(gogoproto.nullable) = false];
32+
33+
34+
repeated LiquidityPoolRecord liquidity_pool_records = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"liquidity_pools\""];
35+
}
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];
12100
}

proto/query.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ message QueryLiquidityPoolRequest {
5252

5353
message QueryLiquidityPoolResponse {
5454
LiquidityPool liquidity_pool = 1 [(gogoproto.nullable) = false];
55-
LiquidityPoolMetaData liquidity_pool_meta_data = 2;
56-
LiquidityPoolBatch liquidity_pool_batch = 3;
55+
LiquidityPoolMetaData liquidity_pool_meta_data = 2 [(gogoproto.nullable) = false];
56+
LiquidityPoolBatch liquidity_pool_batch = 3 [(gogoproto.nullable) = false];
5757
}
5858

5959
message QueryLiquidityPoolBatchRequest {

x/liquidity/genesis.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) {
1818
k.SetParams(ctx, data.Params)
1919
}
2020

21+
// TODO: WIP
2122
// ExportGenesis returns a GenesisState for a given context and keeper.
2223
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState {
23-
return types.NewGenesisState(keeper.GetParams(ctx))
24+
return nil
25+
//return types.NewGenesisState(keeper.GetParams(ctx))
2426
}

x/liquidity/genesis_test.go

Lines changed: 0 additions & 3 deletions
This file was deleted.

x/liquidity/handler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func TestMsgServerSwap(t *testing.T) {
286286
batch, found := simapp.LiquidityKeeper.GetLiquidityPoolBatch(ctx, poolId)
287287
require.True(t, found)
288288
notProcessedMsgs := simapp.LiquidityKeeper.GetAllNotProcessedLiquidityPoolBatchSwapMsgs(ctx, batch)
289-
msgs := simapp.LiquidityKeeper.GetAllLiquidityPoolBatchSwapMsgs(ctx, batch)
289+
msgs := simapp.LiquidityKeeper.GetAllLiquidityPoolBatchSwapMsgsAsPointer(ctx, batch)
290290
require.Equal(t, 4, len(msgs))
291291
require.Equal(t, 4, len(notProcessedMsgs))
292-
}
292+
}

x/liquidity/keeper/genesis.go

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
11
package keeper
22

3-
//import (
4-
// sdk "github.com/cosmos/cosmos-sdk/types"
5-
// "github.com/tendermint/liquidity/x/liquidity/types"
6-
//)
7-
//
8-
//
9-
//func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) {
10-
//
11-
//}
12-
//
13-
//func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
14-
// return nil
15-
//}
3+
import (
4+
sdk "github.com/cosmos/cosmos-sdk/types"
5+
"github.com/tendermint/liquidity/x/liquidity/types"
6+
)
7+
8+
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
9+
k.SetParams(ctx, genState.Params)
10+
11+
}
12+
13+
// TODO: WIP
14+
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
15+
params := k.GetParams(ctx)
16+
var poolRecords []types.LiquidityPoolRecord
17+
18+
pools := k.GetAllLiquidityPools(ctx)
19+
for _, pool := range pools {
20+
record, found := k.GetLiquidityPoolRecord(ctx, pool)
21+
if found {
22+
poolRecords = append(poolRecords, *record)
23+
}
24+
}
25+
return types.NewGenesisState(params, poolRecords)
26+
27+
//
28+
//k.GetAllLiquidityPoolBatches()
29+
//
30+
//k.IterateAllLiquidityPools()
31+
//
32+
//
33+
//// each pool?
34+
//k.GetAllLiquidityPoolBatchSwapMsgsAsPointer(ctx, pool)
35+
//k.GetPoolMetaData(ctx, pool)
36+
//
37+
//k.Iterate
38+
//
39+
//return types.NewGenesisState(params, )
40+
////return types.DefaultGenesisState()
41+
}

x/liquidity/keeper/genesis_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package keeper_test
2+
3+
// TODO:
4+

x/liquidity/keeper/grpc_query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func (k Keeper) MakeQueryLiquidityPoolResponse(ctx sdk.Context, pool types.Liqui
2626
}
2727

2828
return &types.QueryLiquidityPoolResponse{LiquidityPool: pool,
29-
LiquidityPoolMetaData: k.GetLiquidityPoolMetaData(ctx, pool),
30-
LiquidityPoolBatch: &batch}, nil
29+
LiquidityPoolMetaData: *k.GetLiquidityPoolMetaData(ctx, pool),
30+
LiquidityPoolBatch: batch}, nil
3131
}
3232

3333
func (k Keeper) LiquidityPool(c context.Context, req *types.QueryLiquidityPoolRequest) (*types.QueryLiquidityPoolResponse, error) {

0 commit comments

Comments
 (0)