-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: manually trigger periodic task (#492)
## Description Closes: #415 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch - [x] provided a link to the relevant issue or specification - [x] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
- Loading branch information
1 parent
1147d3b
commit a7aa04d
Showing
18 changed files
with
390 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 @@ | ||
package bank | ||
|
||
import ( | ||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewBankCmd returns the Cobra command allowing to fix various things related to the x/bank module | ||
func NewBankCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "bank", | ||
Short: "Fix things related to the x/bank module", | ||
} | ||
|
||
cmd.AddCommand( | ||
supplyCmd(parseConfig), | ||
) | ||
|
||
return cmd | ||
} |
This file contains 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,46 @@ | ||
package bank | ||
|
||
import ( | ||
"fmt" | ||
|
||
modulestypes "github.com/forbole/bdjuno/v3/modules/types" | ||
|
||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/forbole/juno/v3/types/config" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/forbole/bdjuno/v3/database" | ||
"github.com/forbole/bdjuno/v3/modules/bank" | ||
) | ||
|
||
// supplyCmd returns the Cobra command allowing to refresh x/bank total supply | ||
func supplyCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "supply", | ||
Short: "Refresh total supply", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Get the database | ||
db := database.Cast(parseCtx.Database) | ||
|
||
// Build bank module | ||
bankModule := bank.NewModule(nil, sources.BankSource, parseCtx.EncodingConfig.Marshaler, db) | ||
|
||
err = bankModule.UpdateSupply() | ||
if err != nil { | ||
return fmt.Errorf("error while getting latest bank supply: %s", err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains 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 @@ | ||
package distribution | ||
|
||
import ( | ||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewDistributionCmd returns the Cobra command allowing to fix various things related to the x/distribution module | ||
func NewDistributionCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "distribution", | ||
Short: "Fix things related to the x/distribution module", | ||
} | ||
|
||
cmd.AddCommand( | ||
communityPoolCmd(parseConfig), | ||
) | ||
|
||
return cmd | ||
} |
This file contains 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,45 @@ | ||
package distribution | ||
|
||
import ( | ||
"fmt" | ||
|
||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/forbole/juno/v3/types/config" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/forbole/bdjuno/v3/database" | ||
"github.com/forbole/bdjuno/v3/modules/distribution" | ||
modulestypes "github.com/forbole/bdjuno/v3/modules/types" | ||
) | ||
|
||
// communityPoolCmd returns the Cobra command allowing to refresh community pool | ||
func communityPoolCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "community-pool", | ||
Short: "Refresh community pool", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Get the database | ||
db := database.Cast(parseCtx.Database) | ||
|
||
// Build distribution module | ||
distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Marshaler, db) | ||
|
||
err = distrModule.GetLatestCommunityPool() | ||
if err != nil { | ||
return fmt.Errorf("error while updating community pool: %s", err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains 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 @@ | ||
package mint | ||
|
||
import ( | ||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewMintCmd returns the Cobra command allowing to fix various things related to the x/mint module | ||
func NewMintCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "mint", | ||
Short: "Fix things related to the x/mint module", | ||
} | ||
|
||
cmd.AddCommand( | ||
inflationCmd(parseConfig), | ||
) | ||
|
||
return cmd | ||
} |
This file contains 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,45 @@ | ||
package mint | ||
|
||
import ( | ||
"fmt" | ||
|
||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/forbole/juno/v3/types/config" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/forbole/bdjuno/v3/database" | ||
"github.com/forbole/bdjuno/v3/modules/mint" | ||
modulestypes "github.com/forbole/bdjuno/v3/modules/types" | ||
) | ||
|
||
// inflationCmd returns the Cobra command allowing to refresh x/mint inflation | ||
func inflationCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "inflation", | ||
Short: "Refresh inflation", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Get the database | ||
db := database.Cast(parseCtx.Database) | ||
|
||
// Build mint module | ||
mintModule := mint.NewModule(sources.MintSource, parseCtx.EncodingConfig.Marshaler, db) | ||
|
||
err = mintModule.UpdateInflation() | ||
if err != nil { | ||
return fmt.Errorf("error while updating inflation: %s", err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains 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
This file contains 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,21 @@ | ||
package pricefeed | ||
|
||
import ( | ||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewPricefeedCmd returns the Cobra command allowing to refresh pricefeed | ||
func NewPricefeedCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "pricefeed", | ||
Short: "Fix things related to the pricefeed module", | ||
} | ||
|
||
cmd.AddCommand( | ||
priceCmd(parseConfig), | ||
priceHistoryCmd(parseConfig), | ||
) | ||
|
||
return cmd | ||
} |
This file contains 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,44 @@ | ||
package pricefeed | ||
|
||
import ( | ||
"fmt" | ||
|
||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/forbole/juno/v3/types/config" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/forbole/bdjuno/v3/database" | ||
"github.com/forbole/bdjuno/v3/modules/pricefeed" | ||
) | ||
|
||
// priceCmd returns the Cobra command allowing to refresh token price | ||
func priceCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "price", | ||
Short: "Refresh token price", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Get the database | ||
db := database.Cast(parseCtx.Database) | ||
|
||
// Build pricefeed module | ||
pricefeedModule := pricefeed.NewModule(config.Cfg, parseCtx.EncodingConfig.Marshaler, db) | ||
|
||
err = pricefeedModule.RunAdditionalOperations() | ||
if err != nil { | ||
return fmt.Errorf("error while storing tokens: %s", err) | ||
} | ||
|
||
err = pricefeedModule.UpdatePrice() | ||
if err != nil { | ||
return fmt.Errorf("error while updating price: %s", err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains 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,44 @@ | ||
package pricefeed | ||
|
||
import ( | ||
"fmt" | ||
|
||
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" | ||
"github.com/forbole/juno/v3/types/config" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/forbole/bdjuno/v3/database" | ||
"github.com/forbole/bdjuno/v3/modules/pricefeed" | ||
) | ||
|
||
// priceHistoryCmd returns the Cobra command allowing to store token price history | ||
func priceHistoryCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "history", | ||
Short: "Store token price history", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Get the database | ||
db := database.Cast(parseCtx.Database) | ||
|
||
// Build pricefeed module | ||
pricefeedModule := pricefeed.NewModule(config.Cfg, parseCtx.EncodingConfig.Marshaler, db) | ||
|
||
err = pricefeedModule.RunAdditionalOperations() | ||
if err != nil { | ||
return fmt.Errorf("error while storing tokens: %s", err) | ||
} | ||
|
||
err = pricefeedModule.UpdatePricesHistory() | ||
if err != nil { | ||
return fmt.Errorf("error while updating price history: %s", err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains 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
Oops, something went wrong.