Skip to content

Commit

Permalink
typo(oracle): rountId -> roundId
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed Apr 13, 2024
1 parent e51e94a commit e1c48ae
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 115 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ require (
)

replace (

bou.ke/monkey v1.0.2 => /Users/linqing/workplace/github.com/leonz/monkey
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// use Cosmos-SDK fork to enable Ledger functionality
Expand Down
2 changes: 1 addition & 1 deletion proto/exocore/oracle/prices.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types";

message Prices {
int32 token_id = 1;
uint64 next_rount_id = 2;
uint64 next_round_id = 2;
repeated PriceWithTimeAndRound price_list = 3;
}
4 changes: 2 additions & 2 deletions x/oracle/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestGenesis(t *testing.T) {
RoundId: 1,
},
},
NextRountId: 2,
NextRoundId: 2,
},
{
TokenId: 2,
Expand All @@ -43,7 +43,7 @@ func TestGenesis(t *testing.T) {
RoundId: 2,
},
},
NextRountId: 3,
NextRoundId: 3,
},
},
ValidatorUpdateBlock: &types.ValidatorUpdateBlock{},
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/keeper/msg_server_create_price_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var _ = Describe("MsgCreatePrice", func() {
prices := ks.k.GetAllPrices(sdk.UnwrapSDKContext(ks.ctx))
Expect(prices[0]).Should(BeEquivalentTo(types.Prices{
TokenId: 1,
NextRountId: 2,
NextRoundId: 2,
PriceList: []*types.PriceWithTimeAndRound{
{
Price: testdata.PTD2.Price,
Expand Down
4 changes: 2 additions & 2 deletions x/oracle/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (suite *KeeperSuite) TestCreatePriceSingleBlock() {
suite.Equal(2, len(prices.PriceList), "length of price list should be 2 including the 0 index with an empty element as placeholder")
suite.Exactly(types.Prices{
TokenId: 1,
NextRountId: 2,
NextRoundId: 2,
PriceList: []*types.PriceWithTimeAndRound{
{},
{
Expand Down Expand Up @@ -112,7 +112,7 @@ func (suite *KeeperSuite) TestCreatePriceTwoBlock() {
if suite.Equal(true, found) {
suite.Exactly(types.Prices{
TokenId: 1,
NextRountId: 2,
NextRoundId: 2,
PriceList: []*types.PriceWithTimeAndRound{
{},
{
Expand Down
18 changes: 6 additions & 12 deletions x/oracle/keeper/prices.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (k Keeper) SetPrices(ctx sdk.Context, prices types.Prices) {
b := k.cdc.MustMarshal(v)
store.Set(types.PricesRoundKey(v.RoundId), b)
}
store.Set(types.PricesNextRountIdKey, types.Uint64Bytes(prices.NextRountId))
store.Set(types.PricesNextRoundIdKey, types.Uint64Bytes(prices.NextRoundId))
}

// GetPrices returns a prices from its index
Expand All @@ -25,16 +25,10 @@ func (k Keeper) GetPrices(

) (val types.Prices, found bool) {
store := k.getPriceTRStore(ctx, tokenId)
// nextRoundIdB := store.Get(types.PricesNextRountIdKey)
// if nextRoundIdB == nil {
// return val, false
// }

// nextRoundId := binary.BigEndian.Uint64(nextRoundIdB)
nextRoundId := k.GetNextRoundId(ctx, tokenId)

val.TokenId = tokenId
val.NextRountId = nextRoundId
val.NextRoundId = nextRoundId
val.PriceList = make([]*types.PriceWithTimeAndRound, nextRoundId)
//0 roundId is reserved, expect the roundid corresponds to the slice index
val.PriceList[0] = &types.PriceWithTimeAndRound{}
Expand Down Expand Up @@ -88,7 +82,7 @@ func (k Keeper) GetAllPrices(ctx sdk.Context) (list []types.Prices) {
price = types.Prices{TokenId: tokenId}
}
if nextRoundId {
price.NextRountId = binary.BigEndian.Uint64(iterator.Value())
price.NextRoundId = binary.BigEndian.Uint64(iterator.Value())
} else {
var val types.PriceWithTimeAndRound
k.cdc.MustUnmarshal(iterator.Value(), &val)
Expand Down Expand Up @@ -131,7 +125,7 @@ func (k Keeper) GetPriceTRLatest(ctx sdk.Context, tokenId int32) (price types.Pr
// store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PricesKeyPrefix))
// store = prefix.NewStore(store, types.PricesKey(tokenId))
store := k.getPriceTRStore(ctx, tokenId)
nextRoundIdB := store.Get(types.PricesNextRountIdKey)
nextRoundIdB := store.Get(types.PricesNextRoundIdKey)
if nextRoundIdB == nil {
return
}
Expand All @@ -149,7 +143,7 @@ func (k Keeper) GetNextRoundId(ctx sdk.Context, tokenId int32) (nextRoundId uint
nextRoundId = 1
//store := getPriceTRStore(ctx, k.storeKey, tokenId)
store := k.getPriceTRStore(ctx, tokenId)
nextRoundIdB := store.Get(types.PricesNextRountIdKey)
nextRoundIdB := store.Get(types.PricesNextRoundIdKey)
if nextRoundIdB != nil {
if nextRoundId = binary.BigEndian.Uint64(nextRoundIdB); nextRoundId == 0 {
nextRoundId = 1
Expand All @@ -164,7 +158,7 @@ func (k Keeper) IncreaseNextRoundId(ctx sdk.Context, tokenId int32) {
nextRoundId := k.GetNextRoundId(ctx, tokenId)
b := make([]byte, 8)
binary.BigEndian.PutUint64(b, nextRoundId+1)
store.Set(types.PricesNextRountIdKey, b)
store.Set(types.PricesNextRoundIdKey, b)
}

//func getPriceTRStore(ctx sdk.Context, storeKey storetypes.StoreKey, tokenId int32) prefix.Store {
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/keeper/prices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func createNPrices(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Prices
items[i].TokenId = int32(i + 1)
items[i] = types.Prices{
TokenId: int32(i + 1),
NextRountId: 2,
NextRoundId: 2,
PriceList: []*types.PriceWithTimeAndRound{
testdata.PTR1,
testdata.PTR2,
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/keeper/testdata/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newPTR(price string, roundId uint64) *types.PriceWithTimeAndRound {
func newPrices(tokenId int32, nextRoundId uint64, pList ...*types.PriceWithTimeAndRound) types.Prices {
return types.Prices{
TokenId: tokenId,
NextRountId: nextRoundId,
NextRoundId: nextRoundId,
PriceList: pList,
}
}
66 changes: 33 additions & 33 deletions x/oracle/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 28 additions & 29 deletions x/oracle/types/info.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/oracle/types/key_prices.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
)

// PricesNextRoundIdKey is the key set for each tokenId storeKV to store the next round id
var PricesNextRountIdKey = []byte("nextRoundId/")
var PricesNextRoundIdKey = []byte("nextRoundId/")

// PricesKey returns the store key to retrieve a Prices from the index fields
// this key is actually used as the prefix for kvsotre, TODO: refactor to PriceTokenPrefix
Expand Down
Loading

0 comments on commit e1c48ae

Please sign in to comment.