-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cosmos/v0.44.x' of https://github.com/forbole/bdjuno in…
…to chains/agoric/mainnet
- Loading branch information
Showing
43 changed files
with
1,100 additions
and
151 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
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
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 |
---|---|---|
|
@@ -5,25 +5,29 @@ name: Lint | |
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
GolangCI: | ||
name: golangci-lint | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 6 | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: technote-space/[email protected] | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go 🧰 | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Compute diff 📜 | ||
uses: technote-space/[email protected] | ||
with: | ||
SUFFIX_FILTER: | | ||
.go | ||
.mod | ||
.sum | ||
- uses: golangci/[email protected] | ||
with: | ||
version: v1.50.1 | ||
args: --timeout 10m | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Run lint ✅ | ||
if: "env.GIT_DIFF != ''" | ||
run: make lint |
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 |
---|---|---|
|
@@ -4,8 +4,6 @@ name: Tests | |
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
Cleanup-runs: | ||
|
@@ -14,21 +12,38 @@ jobs: | |
- uses: rokroskar/workflow-run-cleanup-action@master | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" | ||
if: "!startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/cosmos')" | ||
|
||
Unit-tests: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go 🧰 | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.20" | ||
- name: Test & Create coverage report | ||
run: make install test-unit stop-docker-test | ||
- name: Upload cove coverage | ||
uses: codecov/codecov-action@v3 | ||
|
||
- name: Compute diff 📜 | ||
uses: technote-space/[email protected] | ||
id: git_diff | ||
with: | ||
SUFFIX_FILTER: | | ||
.go | ||
.mod | ||
.sum | ||
- name: Build 🔨 | ||
if: "env.GIT_DIFF != ''" | ||
run: make build | ||
|
||
- name: Test & Coverage report creation 🧪 | ||
run: make test-unit stop-docker-test | ||
|
||
- name: Upload coverage 📤 | ||
if: "env.GIT_DIFF != ''" | ||
uses: codecov/[email protected] | ||
with: | ||
file: ./coverage.txt |
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 |
---|---|---|
|
@@ -8,7 +8,6 @@ linters: | |
enable: | ||
- bodyclose | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- gocritic | ||
- gofmt | ||
|
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
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
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,43 @@ | ||
package v5 | ||
|
||
import ( | ||
"fmt" | ||
|
||
v5db "github.com/forbole/bdjuno/v4/database/migrate/v5" | ||
parse "github.com/forbole/juno/v5/cmd/parse/types" | ||
"github.com/forbole/juno/v5/database" | ||
"github.com/forbole/juno/v5/database/postgresql" | ||
"github.com/forbole/juno/v5/types/config" | ||
) | ||
|
||
// RunMigration runs the migrations to v5 | ||
func RunMigration(parseConfig *parse.Config) error { | ||
cfg, err := GetConfig() | ||
if err != nil { | ||
return fmt.Errorf("error while reading config: %s", err) | ||
} | ||
|
||
// Migrate the database | ||
err = migrateDb(cfg, parseConfig) | ||
if err != nil { | ||
return fmt.Errorf("error while migrating database: %s", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func migrateDb(cfg config.Config, parseConfig *parse.Config) error { | ||
// Build the codec | ||
encodingConfig := parseConfig.GetEncodingConfigBuilder()() | ||
|
||
// Get the db | ||
databaseCtx := database.NewContext(cfg.Database, &encodingConfig, parseConfig.GetLogger()) | ||
db, err := postgresql.Builder(databaseCtx) | ||
if err != nil { | ||
return fmt.Errorf("error while building the db: %s", err) | ||
} | ||
|
||
// Build the migrator and perform the migrations | ||
migrator := v5db.NewMigrator(db.(*postgresql.Database)) | ||
return migrator.Migrate() | ||
} |
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,29 @@ | ||
package v5 | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
|
||
"github.com/forbole/juno/v5/types/config" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
// GetConfig returns the configuration reading it from the config.yaml file present inside the home directory | ||
func GetConfig() (config.Config, error) { | ||
file := path.Join(config.HomePath, "config.yaml") | ||
|
||
// Make sure the path exists | ||
if _, err := os.Stat(file); os.IsNotExist(err) { | ||
return config.Config{}, fmt.Errorf("config file does not exist") | ||
} | ||
|
||
bz, err := os.ReadFile(file) | ||
if err != nil { | ||
return config.Config{}, fmt.Errorf("error while reading config file: %s", err) | ||
} | ||
|
||
var cfg config.Config | ||
err = yaml.Unmarshal(bz, &cfg) | ||
return cfg, err | ||
} |
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,16 @@ | ||
package database | ||
|
||
import ( | ||
types "github.com/forbole/bdjuno/v4/types" | ||
) | ||
|
||
// SaveMessageType stores the given message type inside the database | ||
func (db *Db) SaveMessageType(msg *types.MessageType) error { | ||
stmt := ` | ||
INSERT INTO message_type(type, module, label, height) | ||
VALUES ($1, $2, $3, $4) | ||
ON CONFLICT (type) DO NOTHING` | ||
|
||
_, err := db.SQL.Exec(stmt, msg.Type, msg.Module, msg.Label, msg.Height) | ||
return err | ||
} |
Oops, something went wrong.