Skip to content
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

feat: Sync bank and staking features to mainnet #64

Merged
merged 22 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9d4632b
ci: Fix syntax error in DOCR push
ankurdotb Nov 3, 2022
690ef81
chore(deps): Bump github.com/prometheus/client_golang from 1.13.0 to …
dependabot[bot] Nov 8, 2022
cb22708
build(deps): bump github.com/prometheus/client_golang from 1.13.0 to …
dependabot[bot] Nov 4, 2022
428c61a
feat: manually trigger periodic task (#492)
huichiaotsou Nov 13, 2022
0a0d1b4
fix: check if proposal has passed voting end time before marking it a…
huichiaotsou Nov 14, 2022
8697594
chore(deps): Bump github.com/go-co-op/gocron from 1.17.1 to 1.18.0 (#61)
dependabot[bot] Nov 24, 2022
8166009
Revert "feat: manually trigger periodic task (#492)"
ankurdotb Nov 24, 2022
2d7cd38
Revert "fix: check if proposal has passed voting end time before mark…
ankurdotb Nov 24, 2022
a3b4723
docs: Update README [skip ci]
ankurdotb Nov 24, 2022
ab50044
feat: Sync upstream `bank` and `staking` features (#63)
ankurdotb Nov 24, 2022
b9d1312
ci: Fix syntax error in DOCR push
ankurdotb Nov 3, 2022
54e722c
ci: Update cache cleaning
ankurdotb Nov 8, 2022
09374e7
chore(deps): Bump github.com/prometheus/client_golang from 1.13.0 to …
dependabot[bot] Nov 8, 2022
aca95cc
chore(deps): Bump github.com/go-co-op/gocron from 1.17.1 to 1.18.0 (#61)
dependabot[bot] Nov 24, 2022
f769496
build(deps): bump github.com/prometheus/client_golang from 1.13.0 to …
dependabot[bot] Nov 4, 2022
cc44ec9
feat: manually trigger periodic task (#492)
huichiaotsou Nov 13, 2022
8ba89e9
fix: check if proposal has passed voting end time before marking it a…
huichiaotsou Nov 14, 2022
e86fc9f
Merge branch 'chains/cheqd/testnet' of https://github.com/cheqd/bdjun…
ankurdotb Nov 24, 2022
a2c755a
Revert "feat: manually trigger periodic task (#492)"
ankurdotb Nov 24, 2022
4d24dc2
Revert "fix: check if proposal has passed voting end time before mark…
ankurdotb Nov 24, 2022
214fed8
docs: Update README [skip ci]
ankurdotb Nov 24, 2022
f1f50e7
feat: Sync upstream `bank` and `staking` features (#63)
ankurdotb Nov 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
defaults:
run:
shell: bash
permissions:
contents: write
packages: write


jobs:
Expand Down
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,36 @@
BDJuno (shorthand for BigDipper Juno) is the [Juno](https://github.com/forbole/juno) implementation
for [BigDipper](https://github.com/forbole/big-dipper).

It extends the custom Juno behavior by adding different handlers and custom operations to make it easier for BigDipper
showing the data inside the UI.

All the chains' data that are queried from the RPC and gRPC endpoints are stored inside
a [PostgreSQL](https://www.postgresql.org/) database on top of which [GraphQL](https://graphql.org/) APIs can then be
created using [Hasura](https://hasura.io/).

## Usage
## Features specific to cheqd

1. Indexing for [cheqd network] DIDs and Resources
2. Changes to workflows/pipelines
3. Optimised Dockerfile

## Developer guide

This section is reproduced as-is from upstream project.

### Usage

To know how to setup and run BDJuno, please refer to
the [docs website](https://docs.bigdipper.live/cosmos-based/parser/overview/).

## Testing

If you want to test the code, you can do so by running

```shell
$ make test-unit
make test-unit
```

**Note**: Requires [Docker](https://docker.com).

This will:

1. Create a Docker container running a PostgreSQL database.
2. Run all the tests using that database as support.


20 changes: 20 additions & 0 deletions cmd/parse/bank/cmd.go
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
}
46 changes: 46 additions & 0 deletions cmd/parse/bank/supply.go
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
},
}
}
20 changes: 20 additions & 0 deletions cmd/parse/distribution/cmd.go
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
}
45 changes: 45 additions & 0 deletions cmd/parse/distribution/communitypool.go
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
},
}
}
3 changes: 2 additions & 1 deletion cmd/parse/gov/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"fmt"
"strconv"
"time"

modulestypes "github.com/forbole/bdjuno/v3/modules/types"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -78,7 +79,7 @@ func proposalCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return fmt.Errorf("error while getting chain latest block height: %s", err)
}

err = govModule.UpdateProposal(height, proposalID)
err = govModule.UpdateProposal(height, time.Now(), proposalID)
if err != nil {
return err
}
Expand Down
20 changes: 20 additions & 0 deletions cmd/parse/mint/cmd.go
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
}
45 changes: 45 additions & 0 deletions cmd/parse/mint/inflation.go
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
},
}
}
8 changes: 8 additions & 0 deletions cmd/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import (
parsegenesis "github.com/forbole/juno/v3/cmd/parse/genesis"

parseauth "github.com/forbole/bdjuno/v3/cmd/parse/auth"
parsebank "github.com/forbole/bdjuno/v3/cmd/parse/bank"
parsedistribution "github.com/forbole/bdjuno/v3/cmd/parse/distribution"
parsefeegrant "github.com/forbole/bdjuno/v3/cmd/parse/feegrant"
parsegov "github.com/forbole/bdjuno/v3/cmd/parse/gov"
parsemint "github.com/forbole/bdjuno/v3/cmd/parse/mint"
parsepricefeed "github.com/forbole/bdjuno/v3/cmd/parse/pricefeed"
parsestaking "github.com/forbole/bdjuno/v3/cmd/parse/staking"
parsetransaction "github.com/forbole/juno/v3/cmd/parse/transactions"
)
Expand All @@ -25,10 +29,14 @@ func NewParseCmd(parseCfg *parse.Config) *cobra.Command {

cmd.AddCommand(
parseauth.NewAuthCmd(parseCfg),
parsebank.NewBankCmd(parseCfg),
parseblocks.NewBlocksCmd(parseCfg),
parsedistribution.NewDistributionCmd(parseCfg),
parsefeegrant.NewFeegrantCmd(parseCfg),
parsegenesis.NewGenesisCmd(parseCfg),
parsegov.NewGovCmd(parseCfg),
parsemint.NewMintCmd(parseCfg),
parsepricefeed.NewPricefeedCmd(parseCfg),
parsestaking.NewStakingCmd(parseCfg),
parsetransaction.NewTransactionsCmd(parseCfg),
)
Expand Down
21 changes: 21 additions & 0 deletions cmd/parse/pricefeed/cmd.go
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
}
44 changes: 44 additions & 0 deletions cmd/parse/pricefeed/price.go
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
},
}
}
Loading