Skip to content

Commit

Permalink
fix: export Codec and LegacyAmino codec in Database wrapper (#96)
Browse files Browse the repository at this point in the history
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v                               ✰  Thanks for creating a PR! ✰    
v    Before smashing the submit button please review the checkboxes.
v If a checkbox is n/a - please still include it but + a little note why
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Description
<!-- Small description -->

## Checklist
- [x] Targeted PR against correct branch.
- [ ] Linked to Github issue with discussion and accepted design OR link
to spec that describes this work.
- [ ] Wrote unit tests.  
- [x] Re-reviewed `Files changed` in the Github PR explorer.
  • Loading branch information
MonikaCat authored Jun 5, 2023
1 parent 54de9e4 commit a95a634
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
### Changes
- Updated Cosmos SDK to `v0.47.2`

### Database
- ([\#96](https://github.com/forbole/juno/pull/96)) Exported Codec and LegacyAmino codec inside Database wrapper

## v4.2.0
### Changes
- ([\#93](https://github.com/forbole/juno/pull/93)) Decode IBC transfer data to JSON for `/ibc.core.channel.v1.MsgRecvPacket` message
Expand Down
16 changes: 8 additions & 8 deletions database/postgresql/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func Builder(ctx *database.Context) (database.Database, error) {
postgresDb.SetMaxIdleConns(ctx.Cfg.MaxIdleConnections)

return &Database{
cdc: ctx.EncodingConfig.Codec,
amino: ctx.EncodingConfig.Amino,
Cdc: ctx.EncodingConfig.Codec,
Amino: ctx.EncodingConfig.Amino,

SQL: postgresDb,
Logger: ctx.Logger,
Expand All @@ -60,8 +60,8 @@ var _ database.Database = &Database{}
// Database defines a wrapper around a SQL database and implements functionality
// for data aggregation and exporting.
type Database struct {
cdc codec.Codec
amino *codec.LegacyAmino
Cdc codec.Codec
Amino *codec.LegacyAmino

SQL *sqlx.DB
Logger logging.Logger
Expand Down Expand Up @@ -194,30 +194,30 @@ ON CONFLICT (hash, partition_id) DO UPDATE

var msgs = make([]string, len(tx.Body.Messages))
for index, msg := range tx.Body.Messages {
bz, err := db.cdc.MarshalJSON(msg)
bz, err := db.Cdc.MarshalJSON(msg)
if err != nil {
return err
}
msgs[index] = string(bz)
}
msgsBz := fmt.Sprintf("[%s]", strings.Join(msgs, ","))

feeBz, err := db.cdc.MarshalJSON(tx.AuthInfo.Fee)
feeBz, err := db.Cdc.MarshalJSON(tx.AuthInfo.Fee)
if err != nil {
return fmt.Errorf("failed to JSON encode tx fee: %s", err)
}

var sigInfos = make([]string, len(tx.AuthInfo.SignerInfos))
for index, info := range tx.AuthInfo.SignerInfos {
bz, err := db.cdc.MarshalJSON(info)
bz, err := db.Cdc.MarshalJSON(info)
if err != nil {
return err
}
sigInfos[index] = string(bz)
}
sigInfoBz := fmt.Sprintf("[%s]", strings.Join(sigInfos, ","))

logsBz, err := db.amino.MarshalJSON(tx.Logs)
logsBz, err := db.Amino.MarshalJSON(tx.Logs)
if err != nil {
return err
}
Expand Down

0 comments on commit a95a634

Please sign in to comment.