Skip to content

Commit

Permalink
update inflation query to call API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MonikaCat committed Jun 16, 2023
1 parent c557098 commit 7a08670
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#### Staking Module
- ([\#443](https://github.com/forbole/bdjuno/pull/443)) Remove tombstone status from staking module(already stored in slashing module)
- ([\#455](https://github.com/forbole/bdjuno/pull/455)) Added `unbonding_tokens` and `staked_not_bonded_tokens` values to staking pool table
- ([\#536](https://github.com/forbole/bdjuno/pull/536) Fix `PoolSnapshot` tokens type from `sdk.Int` to `sdkmath.Int`
- ([\#536](https://github.com/forbole/bdjuno/pull/536)) Fix `PoolSnapshot` tokens type from `sdk.Int` to `sdkmath.Int`

#### Gov Module
- ([\#461](https://github.com/forbole/bdjuno/pull/461)) Parse `x/gov` genesis with `genesisDoc.InitialHeight` instead of the hard-coded height 1
Expand Down
6 changes: 2 additions & 4 deletions cmd/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import (
parse "github.com/forbole/juno/v4/cmd/parse/types"
"github.com/spf13/cobra"

parseblocks "github.com/forbole/juno/v4/cmd/parse/blocks"

parsegenesis "github.com/forbole/juno/v4/cmd/parse/genesis"

parseauth "github.com/forbole/bdjuno/v4/cmd/parse/auth"
parsebank "github.com/forbole/bdjuno/v4/cmd/parse/bank"
parsedistribution "github.com/forbole/bdjuno/v4/cmd/parse/distribution"
Expand All @@ -16,6 +12,8 @@ import (
parsemint "github.com/forbole/bdjuno/v4/cmd/parse/mint"
parsepricefeed "github.com/forbole/bdjuno/v4/cmd/parse/pricefeed"
parsestaking "github.com/forbole/bdjuno/v4/cmd/parse/staking"
parseblocks "github.com/forbole/juno/v4/cmd/parse/blocks"
parsegenesis "github.com/forbole/juno/v4/cmd/parse/genesis"
parsetransaction "github.com/forbole/juno/v4/cmd/parse/transactions"
)

Expand Down
2 changes: 1 addition & 1 deletion modules/feegrant/handle_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (m *Module) removeExpiredFeeGrantAllowances(height int64, events []abci.Eve
if err != nil {
return fmt.Errorf("error while getting fee grant grantee address: %s", err)
}
err = m.db.DeleteFeeGrantAllowance(types.NewGrantRemoval(string(granteeAddress.Value), string(granterAddress.Value), height))
err = m.db.DeleteFeeGrantAllowance(types.NewGrantRemoval(granteeAddress.Value, granterAddress.Value, height))
if err != nil {
return fmt.Errorf("error while deleting fee grant allowance: %s", err)

Expand Down
27 changes: 23 additions & 4 deletions modules/mint/handle_periodic_operations.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package mint

import (
"github.com/forbole/bdjuno/v4/modules/utils"
"encoding/json"
"fmt"
"io"
"net/http"

minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"

"github.com/forbole/bdjuno/v4/modules/utils"
"github.com/go-co-op/gocron"
"github.com/rs/zerolog/log"
)
Expand Down Expand Up @@ -35,10 +41,23 @@ func (m *Module) UpdateInflation() error {
}

// Get the inflation
inflation, err := m.source.GetInflation(height)
resp, err := http.Get("https://api.humansai.forbole.com/cosmos/mint/v1beta1/inflation")
if err != nil {
return err
return fmt.Errorf("error while querying API for inflation value: %s", err)
}

defer resp.Body.Close()

bz, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("error while reading response body: %s", err)
}

var inf minttypes.QueryInflationResponse
err = json.Unmarshal(bz, &inf)
if err != nil {
return fmt.Errorf("error while unmarshaling response body: %s", err)
}

return m.db.SaveInflation(inflation, height)
return m.db.SaveInflation(inf.Inflation, height)
}

0 comments on commit 7a08670

Please sign in to comment.