forked from CosmWasm/wasmd
-
Notifications
You must be signed in to change notification settings - Fork 10
Feat/txfees #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat/txfees #85
Changes from 22 commits
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
971a425
add specs for txfees
GNaD13 04c87da
proposal
GNaD13 30abf74
nit
GNaD13 63d96d9
Merge pull request #78 from oraichain/txfees-module-design
GNaD13 325943a
app module interface
GNaD13 3cdef3e
gen proto
GNaD13 a9cdd1b
add params and genesis
GNaD13 0195c14
done module structure
GNaD13 7b9e970
Merge pull request #81 from oraichain/dang/module-interface
GNaD13 09eb9cd
add token list store function
GNaD13 0bf505f
done store
GNaD13 feba391
Merge pull request #82 from oraichain/dang/txfees-module-store
GNaD13 51b3dcd
add params
GNaD13 b5a421e
proposal add update params
GNaD13 e889460
add msg fee token
GNaD13 d13f3aa
add comment
GNaD13 e0f9330
nit
GNaD13 37c2e1b
Merge pull request #83 from oraichain/dang/add-proposal-add-fee-token
GNaD13 b6385ea
query contract spot price
GNaD13 68c3b96
nit
GNaD13 2d208ab
epoch
GNaD13 1b6860c
Merge pull request #84 from oraichain/dang/query-spot-price
GNaD13 5e37ea5
nit
GNaD13 9709634
deduct fees
GNaD13 bb0b5e3
add mempool ante
GNaD13 6d40930
Merge pull request #87 from oraichain/dang/ante-handlers
GNaD13 b424f86
genesis
GNaD13 b0c44ba
params and genesis
GNaD13 54e8002
nit
GNaD13 5316b5e
Merge pull request #89 from oraichain/params-and-genesis
GNaD13 0f1ad5d
Merge remote-tracking branch 'orai-ssh/release/v0.50.x' into feat/txfees
GNaD13 cdbb2d4
Merge remote-tracking branch 'orai-ssh/feat/txfees' into feat/txfees
GNaD13 8f40d0c
update dependency with new globalfee ante
GNaD13 929b5e2
Merge pull request #90 from oraichain/dependency
GNaD13 3c1c3e7
add txfees module
GNaD13 86b1049
nit
GNaD13 7e8ac24
Merge pull request #91 from oraichain/integrate-with-app.go
GNaD13 d1e4974
allowed token store test
GNaD13 49fdbd5
nit
GNaD13 6118bf1
add store test
GNaD13 7dfef18
ante
GNaD13 e08935f
Merge pull request #93 from oraichain/setup-integration-test
GNaD13 240fc49
Merge remote-tracking branch 'orai-ssh/release/v0.50.x' into feat/txfees
GNaD13 2b19f85
add test epoch
GNaD13 f113a05
Merge pull request #94 from oraichain/test-epoch
GNaD13 f9e5170
add test exchange rate
GNaD13 befae2c
nit
GNaD13 25e5ca6
nit
GNaD13 52a2fa5
nit
GNaD13 e165dc1
Merge pull request #95 from oraichain/test-epoch
GNaD13 a91481d
nit
GNaD13 c4b38bf
add txfees keeper to ante
GNaD13 c7ee021
Merge branch 'feat/txfees' into test-msg-server
GNaD13 c26f616
add log debug
GNaD13 f0a9460
nit
GNaD13 f9f7651
nit
GNaD13 6105afe
nit
GNaD13 c80c0ce
fix bug genesis
GNaD13 afbf24a
nit
GNaD13 5c1bc02
Merge pull request #96 from oraichain/test-msg-server
GNaD13 c90117d
add msg add fee token test
GNaD13 68b6302
Merge pull request #97 from oraichain/test-msg-server
GNaD13 cb8ede6
nit
GNaD13 1933c73
nit
GNaD13 f89ba4a
add script for deploy contract & update price query wasm new version
Drizzle210 2d7ca5e
add more test
GNaD13 4df628e
Merge pull request #99 from oraichain/test-msg-server
GNaD13 db98b95
merge script deploy price query contract
Drizzle210 d5ecd37
Merge pull request #98 from Drizzle210/feat/txfees
GNaD13 2a787de
feat: add query allowed tokens
ledanghuy1811 f93edbb
feat: add query for tokens config
ledanghuy1811 74fa891
feat: add query token config
ledanghuy1811 a24c5c4
feat: add query token exchange rate
ledanghuy1811 e43e568
Merge pull request #100 from oraichain/feat/implement-txfees-grpc-query
ledanghuy1811 8b042fa
fix
GNaD13 37af7ea
Merge pull request #101 from oraichain/fix-scripts-test
GNaD13 5289d24
Merge branch 'feat/txfees' into add-interchaintest
GNaD13 ceea8b9
Merge remote-tracking branch 'orai-ssh/feat/txfees' into add-intercha…
GNaD13 dcd8028
feat: add base for cli query
ledanghuy1811 ba42b40
feat: add params cli query
ledanghuy1811 caa54bf
feat: add query allowed tokens cli
ledanghuy1811 c216d70
feat: add query token exchange rate cli
ledanghuy1811 80da77c
feat: add query tokens config cli
ledanghuy1811 84db706
feat: add query token config cli
ledanghuy1811 cc79c28
set up test
GNaD13 688b572
Merge pull request #102 from oraichain/feat/txfees-cli-query
ledanghuy1811 9baa546
Merge remote-tracking branch 'orai-ssh/feat/txfees' into add-intercha…
GNaD13 93b6ee8
nit
GNaD13 95d30a3
nit
GNaD13 5bd2288
done interchain e2e test
GNaD13 a31a1e4
nit
GNaD13 c0e28e7
nit
GNaD13 4846525
add workflow
GNaD13 4da2d9d
Merge pull request #103 from oraichain/add-interchaintest
GNaD13 a20fdf4
add upgrade handlers
GNaD13 f6a2711
nit
GNaD13 e1e8d85
nit
GNaD13 7fbf8ad
Merge pull request #104 from oraichain/add-upgrade-handlers
GNaD13 16291c1
nit
GNaD13 2f16f41
nit
GNaD13 8c9a7b8
feat: add base script test
ledanghuy1811 4d8247d
feat: add script test for txfees
ledanghuy1811 afc3145
Merge pull request #106 from oraichain/feat/script-test-txfees
ledanghuy1811 d500c27
change to continue instead of panic when iterate epoch
GNaD13 b75542a
Merge remote-tracking branch 'orai-ssh/feat/txfees' into feat/txfees
GNaD13 df5942e
change design to query in ante
GNaD13 6bdae34
fix ict
GNaD13 1b8e3c7
Merge pull request #107 from oraichain/move-query-in-ante
GNaD13 bf2ad98
feat: update script test for txfees
ledanghuy1811 70ddf41
Merge pull request #108 from oraichain/feat/script-test-txfees
ledanghuy1811 e1e12bd
add test ante
GNaD13 c8f4c5a
nit
GNaD13 e75a8b4
Merge pull request #109 from oraichain/ante_test
GNaD13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
syntax = "proto3"; | ||
package cosmwasm.txfees.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "google/protobuf/duration.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
import "cosmwasm/txfees/v1/params.proto"; | ||
|
||
option go_package = "github.com/CosmWasm/wasmd/x/txfees/types"; | ||
|
||
// EpochInfo defines information of a epoch | ||
message EpochInfo { | ||
// identifier is a unique reference to this particular timer. | ||
string identifier = 1; | ||
// start_time is the time at which the timer first ever ticks. | ||
// If start_time is in the future, the epoch will not begin until the start | ||
// time. | ||
google.protobuf.Timestamp start_time = 2 [ | ||
(gogoproto.stdtime) = true, | ||
(gogoproto.nullable) = false, | ||
(gogoproto.moretags) = "yaml:\"start_time\"" | ||
]; | ||
// duration is the time in between epoch ticks. | ||
// In order for intended behavior to be met, duration should | ||
// be greater than the chains expected block time. | ||
// Duration must be non-zero. | ||
google.protobuf.Duration duration = 3 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.stdduration) = true, | ||
(gogoproto.jsontag) = "duration,omitempty", | ||
(gogoproto.moretags) = "yaml:\"duration\"" | ||
]; | ||
// current_epoch is the current epoch number, or in other words, | ||
// how many times has the timer 'ticked'. | ||
// The first tick (current_epoch=1) is defined as | ||
// the first block whose blocktime is greater than the EpochInfo start_time. | ||
int64 current_epoch = 4; | ||
// current_epoch_start_time describes the start time of the current timer | ||
// interval. The interval is (current_epoch_start_time, | ||
// current_epoch_start_time + duration] When the timer ticks, this is set to | ||
// current_epoch_start_time = last_epoch_start_time + duration only one timer | ||
// tick for a given identifier can occur per block. | ||
// | ||
// NOTE! The current_epoch_start_time may diverge significantly from the | ||
// wall-clock time the epoch began at. Wall-clock time of epoch start may be | ||
// >> current_epoch_start_time. Suppose current_epoch_start_time = 10, | ||
// duration = 5. Suppose the chain goes offline at t=14, and comes back online | ||
// at t=30, and produces blocks at every successive time. (t=31, 32, etc.) | ||
// * The t=30 block will start the epoch for (10, 15] | ||
// * The t=31 block will start the epoch for (15, 20] | ||
// * The t=32 block will start the epoch for (20, 25] | ||
// * The t=33 block will start the epoch for (25, 30] | ||
// * The t=34 block will start the epoch for (30, 35] | ||
// * The **t=36** block will start the epoch for (35, 40] | ||
google.protobuf.Timestamp current_epoch_start_time = 5 [ | ||
(gogoproto.stdtime) = true, | ||
(gogoproto.nullable) = false, | ||
(gogoproto.moretags) = "yaml:\"current_epoch_start_time\"" | ||
]; | ||
// epoch_counting_started is a boolean, that indicates whether this | ||
// epoch timer has began yet. | ||
bool epoch_counting_started = 6; | ||
reserved 7; | ||
// current_epoch_start_height is the block height at which the current epoch | ||
// started. (The block height at which the timer last ticked) | ||
int64 current_epoch_start_height = 8; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
syntax = "proto3"; | ||
package cosmwasm.txfees.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmwasm/txfees/v1/params.proto"; | ||
|
||
option go_package = "github.com/CosmWasm/wasmd/x/txfees/types"; | ||
|
||
enum FeeTokenStatus { | ||
UPDATED = 0; | ||
OUTDATED = 1; | ||
FROZEN = 2; | ||
} | ||
|
||
message FeeTokenConfiguration { | ||
string denom = 1; | ||
string pool_id = 2; | ||
FeeTokenStatus status = 3; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
package cosmwasm.txfees.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmwasm/txfees/v1/params.proto"; | ||
|
||
option go_package = "github.com/CosmWasm/wasmd/x/txfees/types"; | ||
|
||
// GenesisState defines the txfees module's genesis state. | ||
message GenesisState { | ||
// params defines the paramaters of the module. | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
package cosmwasm.txfees.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
option go_package = "github.com/CosmWasm/wasmd/x/txfees/types"; | ||
|
||
// Params defines the parameters for the txfees module. | ||
message Params { | ||
string price_contract_address = 1; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
syntax = "proto3"; | ||
package cosmwasm.txfees.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "cosmos/base/query/v1beta1/pagination.proto"; | ||
import "cosmwasm/txfees/v1/params.proto"; | ||
|
||
option go_package = "github.com/CosmWasm/wasmd/x/txfees/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Params defines a gRPC query method that returns the txfees module's | ||
// parameters. | ||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
option (google.api.http).get = "/cosmwasm/txfees/v1/params"; | ||
} | ||
|
||
} | ||
|
||
// QueryParamsRequest is the request type for the Query/Params RPC method. | ||
message QueryParamsRequest {} | ||
|
||
// QueryParamsResponse is the response type for the Query/Params RPC method. | ||
message QueryParamsResponse { | ||
// params defines the parameters of the module. | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
syntax = "proto3"; | ||
package cosmwasm.txfees.v1; | ||
|
||
import "cosmos/msg/v1/msg.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "amino/amino.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "cosmos/bank/v1beta1/bank.proto"; | ||
import "cosmwasm/txfees/v1/params.proto"; | ||
import "cosmwasm/txfees/v1/fee_token.proto"; | ||
|
||
option go_package = "github.com/CosmWasm/wasmd/x/txfees/types"; | ||
|
||
// Msg defines the tokefactory module's gRPC message service. | ||
service Msg { | ||
option (cosmos.msg.v1.service) = true; | ||
|
||
// Update module params | ||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); | ||
|
||
rpc AddFeeToken(MsgAddFeeToken) returns (MsgAddFeeTokenResponse); | ||
|
||
rpc RemoveFeeToken(MsgRemoveFeeToken) returns (MsgRemoveFeeTokenResponse); | ||
} | ||
|
||
message MsgUpdateParams{ | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// authority is the address that controls the module (defaults to x/gov unless overwritten). | ||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; | ||
option (amino.name) = "cosmwasm/x/txfees/MsgUpdateParams"; | ||
|
||
// params defines the x/fees parameters to update. | ||
// | ||
// NOTE: All parameters must be supplied. | ||
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; | ||
} | ||
|
||
message MsgUpdateParamsResponse {} | ||
|
||
message MsgAddFeeToken{ | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// authority is the address that controls the module (defaults to x/gov unless overwritten). | ||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; | ||
|
||
FeeTokenConfiguration config = 2 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
message MsgAddFeeTokenResponse {} | ||
|
||
message MsgRemoveFeeToken{ | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// authority is the address that controls the module (defaults to x/gov unless overwritten). | ||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; | ||
|
||
string denom = 2; | ||
} | ||
|
||
message MsgRemoveFeeTokenResponse {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/CosmWasm/wasmd/x/txfees/types" | ||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func (k Keeper) BeginBlock(ctx sdk.Context) error { | ||
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { | ||
logger := k.Logger(ctx) | ||
|
||
// If blocktime < initial epoch start time, return | ||
if ctx.BlockTime().Before(epochInfo.StartTime) { | ||
return false | ||
} | ||
// if epoch counting hasn't started, signal we need to start. | ||
shouldInitialEpochStart := !epochInfo.EpochCountingStarted | ||
|
||
epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) | ||
shouldEpochStart := (ctx.BlockTime().After(epochEndTime)) || shouldInitialEpochStart | ||
|
||
if !shouldEpochStart { | ||
logger.Info(fmt.Sprintf("Epoch with identifier %s has not ended yet", epochInfo.Identifier)) | ||
return false | ||
} | ||
epochInfo.CurrentEpochStartHeight = ctx.BlockHeight() | ||
|
||
if shouldInitialEpochStart { | ||
epochInfo.EpochCountingStarted = true | ||
epochInfo.CurrentEpoch = 1 | ||
epochInfo.CurrentEpochStartTime = epochInfo.StartTime | ||
logger.Info(fmt.Sprintf("Starting new epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) | ||
} else { | ||
k.AfterEpochEnd(ctx, epochInfo.Identifier) | ||
epochInfo.CurrentEpoch++ | ||
epochInfo.CurrentEpochStartTime = epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) | ||
logger.Info(fmt.Sprintf("Starting epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) | ||
} | ||
|
||
// emit new epoch start event, set epoch info, and run BeforeEpochStart hook | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeEpochStart, | ||
sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochInfo.CurrentEpoch)), | ||
sdk.NewAttribute(types.AttributeEpochStartTime, fmt.Sprintf("%d", epochInfo.CurrentEpochStartTime.Unix())), | ||
), | ||
) | ||
if err := k.SetEpochInfo(ctx, epochInfo); err != nil { | ||
k.Logger(ctx).Error(fmt.Sprintf("error setting epoch info: %s", err.Error())) | ||
return true | ||
} | ||
return false | ||
}) | ||
return nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
storetypes "cosmossdk.io/store/types" | ||
"github.com/CosmWasm/wasmd/x/txfees/types" | ||
"github.com/cosmos/cosmos-sdk/runtime" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func (k Keeper) HasEpochInfo(ctx sdk.Context, identifier string) (bool, error) { | ||
store := k.storeService.OpenKVStore(ctx) | ||
key := types.GetEpochKey(identifier) | ||
|
||
has, err := store.Has(key) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
return has, nil | ||
} | ||
|
||
func (k Keeper) SetEpochInfo(ctx sdk.Context, epoch types.EpochInfo) error { | ||
store := k.storeService.OpenKVStore(ctx) | ||
key := types.GetEpochKey(epoch.Identifier) | ||
|
||
bz, err := k.cdc.Marshal(&epoch) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return store.Set(key, bz) | ||
} | ||
|
||
func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) (types.EpochInfo, bool) { | ||
store := k.storeService.OpenKVStore(ctx) | ||
key := types.GetEpochKey(identifier) | ||
|
||
bz, err := store.Get(key) | ||
if bz == nil || err != nil { | ||
return types.EpochInfo{}, false | ||
} | ||
|
||
epoch := types.EpochInfo{} | ||
err = k.cdc.Unmarshal(bz, &epoch) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return epoch, true | ||
} | ||
|
||
func (k Keeper) AddEpochInfo(ctx sdk.Context, epoch types.EpochInfo) error { | ||
err := epoch.Validate() | ||
if err != nil { | ||
return err | ||
} | ||
// Check if identifier already exists | ||
if has, _ := k.HasEpochInfo(ctx, epoch.Identifier); !has { | ||
return fmt.Errorf("epoch with identifier %s already exists", epoch.Identifier) | ||
} | ||
|
||
// Initialize empty and default epoch values | ||
if epoch.StartTime.Equal(time.Time{}) { | ||
epoch.StartTime = ctx.BlockTime() | ||
} | ||
epoch.CurrentEpochStartHeight = ctx.BlockHeight() | ||
return k.SetEpochInfo(ctx, epoch) | ||
} | ||
|
||
func (k Keeper) IterateEpochInfo(ctx sdk.Context, cb func(index int64, epochInfo types.EpochInfo) (stop bool)) { | ||
store := k.storeService.OpenKVStore(ctx) | ||
|
||
iterator := storetypes.KVStorePrefixIterator(runtime.KVStoreAdapter(store), types.EpochKeyPrefix) | ||
defer iterator.Close() | ||
|
||
i := int64(0) | ||
|
||
for ; iterator.Valid(); iterator.Next() { | ||
epoch := types.EpochInfo{} | ||
err := k.cdc.Unmarshal(iterator.Value(), &epoch) | ||
if err != nil { | ||
panic(err) | ||
|
||
} | ||
|
||
stop := cb(i, epoch) | ||
if stop { | ||
break | ||
} | ||
i++ | ||
} | ||
} | ||
|
||
func (k Keeper) AllEpochInfos(ctx sdk.Context) []types.EpochInfo { | ||
epochs := []types.EpochInfo{} | ||
k.IterateEpochInfo(ctx, func(index int64, epoch types.EpochInfo) (stop bool) { | ||
epochs = append(epochs, epoch) | ||
return false | ||
}) | ||
|
||
return epochs | ||
} | ||
|
||
func (k Keeper) AfterEpochEnd(ctx sdk.Context, identifier string) { | ||
switch identifier { | ||
case types.DefaultQueryEpochIdentifier: | ||
k.IterateAllowedTokenList(ctx, func(denom string) (stop bool) { | ||
k.QueryOraiDexTokenExchangeRate(ctx, denom) | ||
return false | ||
}) | ||
default: | ||
k.Logger(ctx).Error((fmt.Sprintf("unknown epoch %s", identifier))) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.