From d8c5440f8d847592a9f94c35862cfba4bdc43605 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Tue, 1 Nov 2022 13:38:54 +0100 Subject: [PATCH] feat: Hasura permissions and actions improvements (#54) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * build(deps): bump github.com/spf13/cobra from 1.6.0 to 1.6.1 (#488) Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.6.0 to 1.6.1.
Release notes

Sourced from github.com/spf13/cobra's releases.

v1.6.1

Bug fixes 🐛

  • Fixes a panic when AddGroup isn't called before AddCommand(my-sub-command) is executed. This can happen within more complex cobra file structures that have many different inits to be executed. Now, the check for groups has been moved to ExecuteC and provides more flexibility when working with grouped commands - @​marckhouzam (and shout out to @​aawsome, @​andig and @​KINGSABRI for a deep investigation into this! 👏🏼)
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/spf13/cobra&package-manager=go_modules&previous-version=1.6.0&new-version=1.6.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
* fix: improve Hasura permissions (#473) Closes: #XXXX --- *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... - [ ] 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 - [ ] targeted the correct branch - [ ] provided a link to the relevant issue or specification - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed *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) * feat: remove block height foreign key from propoval vote and deposit, add timestamp column (#489) block height foreign key on `proposal_vote` and `proposal_deposit` tables is getting `parse genesis-file` errors because the block table could be empty at the time of parsing genesis. It results in the error like `pq: insert or update on table "proposal_deposit" violates foreign key constraint "proposal_deposit_height_fkey"` Add `timestamp` column so frontend can access this data. --- *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 - [ ] 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 *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) * feat: add host address to hasura actions (#491) Fixes #490 --- *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 *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) * Fix merge conflicts * fix: Linting * Switch struct order in gov database types * Switch Config struct * Update gov.go * Update .golangci.yaml * Sync linter with upstream Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Magic Cat <37407870+MonikaCat@users.noreply.github.com> Co-authored-by: Aaron <76254323+huichiaotsou@users.noreply.github.com> Co-authored-by: jay-dee7 --- .github/linters/.golangci.yaml | 22 +++++----- cmd/migrate/v3/migrate.go | 2 +- database/gov.go | 15 ++++--- database/gov_test.go | 44 +++++++++++-------- database/schema/08-gov.sql | 6 ++- database/types/gov.go | 24 ++++++---- .../bdjuno/tables/public_account.yaml | 3 +- ...ublic_average_block_time_from_genesis.yaml | 3 +- .../public_average_block_time_per_day.yaml | 3 +- .../public_average_block_time_per_hour.yaml | 3 +- .../public_average_block_time_per_minute.yaml | 3 +- .../databases/bdjuno/tables/public_block.yaml | 3 +- .../bdjuno/tables/public_community_pool.yaml | 3 +- .../tables/public_distribution_params.yaml | 4 +- .../tables/public_double_sign_evidence.yaml | 11 +---- .../tables/public_double_sign_vote.yaml | 17 +------ .../tables/public_fee_grant_allowance.yaml | 4 +- .../bdjuno/tables/public_genesis.yaml | 13 ++---- .../bdjuno/tables/public_gov_params.yaml | 4 +- .../bdjuno/tables/public_inflation.yaml | 9 +--- .../bdjuno/tables/public_message.yaml | 4 +- .../bdjuno/tables/public_mint_params.yaml | 4 +- .../bdjuno/tables/public_modules.yaml | 3 +- .../bdjuno/tables/public_pre_commit.yaml | 13 +----- .../bdjuno/tables/public_proposal.yaml | 1 + .../tables/public_proposal_deposit.yaml | 4 +- ...public_proposal_staking_pool_snapshot.yaml | 3 +- .../tables/public_proposal_tally_result.yaml | 3 +- ...ic_proposal_validator_status_snapshot.yaml | 4 +- .../bdjuno/tables/public_proposal_vote.yaml | 12 ++++- .../bdjuno/tables/public_slashing_params.yaml | 4 +- .../bdjuno/tables/public_staking_params.yaml | 4 +- .../bdjuno/tables/public_staking_pool.yaml | 3 +- .../bdjuno/tables/public_supply.yaml | 3 +- .../databases/bdjuno/tables/public_token.yaml | 3 +- .../bdjuno/tables/public_token_price.yaml | 4 +- .../tables/public_token_price_history.yaml | 3 +- .../bdjuno/tables/public_token_unit.yaml | 3 +- .../bdjuno/tables/public_transaction.yaml | 4 +- .../bdjuno/tables/public_validator.yaml | 3 +- .../tables/public_validator_commission.yaml | 3 +- .../tables/public_validator_description.yaml | 3 +- .../bdjuno/tables/public_validator_info.yaml | 3 +- .../tables/public_validator_signing_info.yaml | 3 +- .../tables/public_validator_status.yaml | 1 + .../tables/public_validator_voting_power.yaml | 1 + .../bdjuno/tables/public_vesting_account.yaml | 4 +- .../bdjuno/tables/public_vesting_period.yaml | 4 +- modules/actions/config.go | 16 +++++-- .../actions/handle_additional_operations.go | 2 +- modules/actions/types/worker.go | 5 ++- modules/gov/handle_genesis.go | 9 ++-- modules/gov/handle_msg.go | 24 ++++++++-- types/config/config.go | 4 +- types/gov.go | 13 ++++-- 55 files changed, 211 insertions(+), 165 deletions(-) diff --git a/.github/linters/.golangci.yaml b/.github/linters/.golangci.yaml index a9a862e73..4ceb4dd97 100644 --- a/.github/linters/.golangci.yaml +++ b/.github/linters/.golangci.yaml @@ -1,27 +1,29 @@ run: tests: false # # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 10m + timeout: 5m linters: disable-all: true enable: - bodyclose - - unused + - deadcode - depguard - dogsled - gocritic - gofmt - goimports - - revive + - golint - gosec - gosimple - govet - ineffassign + - maligned - misspell - nakedret - - exportloopref + - scopelint - staticcheck + - structcheck - stylecheck - typecheck - unconvert @@ -37,10 +39,10 @@ issues: - gosec - text: "comment on exported var" linters: - - revive + - golint - text: "don't use an underscore in package name" linters: - - revive + - golint - text: "ST1003:" linters: - stylecheck @@ -55,14 +57,14 @@ issues: linters-settings: dogsled: max-blank-identifiers: 3 + maligned: + # print struct with more effective memory layout or not, false by default + suggest-new: true nolintlint: allow-unused: false allow-leading-space: true require-explanation: false - require-specific: false + require-specific: false misspell: ignore-words: - cheqd - govet: - enable: - - fieldalignment diff --git a/cmd/migrate/v3/migrate.go b/cmd/migrate/v3/migrate.go index 5b08bd0c7..f829d7bb0 100644 --- a/cmd/migrate/v3/migrate.go +++ b/cmd/migrate/v3/migrate.go @@ -56,7 +56,7 @@ func migrateConfig() (Config, error) { } if cfg.Actions == nil { - cfg.Actions = actions.NewConfig(3000, nil) + cfg.Actions = actions.NewConfig("127.0.0.1", 3000, nil) } return cfg, nil diff --git a/database/gov.go b/database/gov.go index 97585a3ea..426af410b 100644 --- a/database/gov.go +++ b/database/gov.go @@ -247,15 +247,16 @@ func (db *Db) SaveDeposits(deposits []types.Deposit) error { return nil } - query := `INSERT INTO proposal_deposit (proposal_id, depositor_address, amount, height) VALUES ` + query := `INSERT INTO proposal_deposit (proposal_id, depositor_address, amount, timestamp, height) VALUES ` var param []interface{} for i, deposit := range deposits { - vi := i * 4 - query += fmt.Sprintf("($%d,$%d,$%d,$%d),", vi+1, vi+2, vi+3, vi+4) + vi := i * 5 + query += fmt.Sprintf("($%d,$%d,$%d,$%d,$%d),", vi+1, vi+2, vi+3, vi+4, vi+5) param = append(param, deposit.ProposalID, deposit.Depositor, pq.Array(dbtypes.NewDbCoins(deposit.Amount)), + deposit.Timestamp, deposit.Height, ) } @@ -263,6 +264,7 @@ func (db *Db) SaveDeposits(deposits []types.Deposit) error { query += ` ON CONFLICT ON CONSTRAINT unique_deposit DO UPDATE SET amount = excluded.amount, + timestamp = excluded.timestamp, height = excluded.height WHERE proposal_deposit.height <= excluded.height` _, err := db.Sql.Exec(query, param...) @@ -278,10 +280,11 @@ WHERE proposal_deposit.height <= excluded.height` // SaveVote allows to save for the given height and the message vote func (db *Db) SaveVote(vote types.Vote) error { query := ` -INSERT INTO proposal_vote (proposal_id, voter_address, option, height) -VALUES ($1, $2, $3, $4) +INSERT INTO proposal_vote (proposal_id, voter_address, option, timestamp, height) +VALUES ($1, $2, $3, $4, $5) ON CONFLICT ON CONSTRAINT unique_vote DO UPDATE SET option = excluded.option, + timestamp = excluded.timestamp, height = excluded.height WHERE proposal_vote.height <= excluded.height` @@ -291,7 +294,7 @@ WHERE proposal_vote.height <= excluded.height` return fmt.Errorf("error while storing voter account: %s", err) } - _, err = db.Sql.Exec(query, vote.ProposalID, vote.Voter, vote.Option.String(), vote.Height) + _, err = db.Sql.Exec(query, vote.ProposalID, vote.Voter, vote.Option.String(), vote.Timestamp, vote.Height) if err != nil { return fmt.Errorf("error while storing vote: %s", err) } diff --git a/database/gov_test.go b/database/gov_test.go index 04143efe6..63fd0faa5 100644 --- a/database/gov_test.go +++ b/database/gov_test.go @@ -348,19 +348,23 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveDeposits() { depositor3 := suite.getAccount("cosmos1gyds87lg3m52hex9yqta2mtwzw89pfukx3jl7g") amount3 := sdk.NewCoins(sdk.NewCoin("desmos", sdk.NewInt(50000))) + timestamp1 := time.Date(2020, 1, 1, 15, 00, 00, 000, time.UTC) + timestamp2 := time.Date(2020, 1, 1, 16, 00, 00, 000, time.UTC) + timestamp3 := time.Date(2020, 1, 1, 17, 00, 00, 000, time.UTC) + deposit := []types.Deposit{ - types.NewDeposit(proposal.ProposalID, depositor.String(), amount, 10), - types.NewDeposit(proposal.ProposalID, depositor2.String(), amount2, 10), - types.NewDeposit(proposal.ProposalID, depositor3.String(), amount3, 10), + types.NewDeposit(proposal.ProposalID, depositor.String(), amount, timestamp1, 10), + types.NewDeposit(proposal.ProposalID, depositor2.String(), amount2, timestamp2, 10), + types.NewDeposit(proposal.ProposalID, depositor3.String(), amount3, timestamp3, 10), } err := suite.database.SaveDeposits(deposit) suite.Require().NoError(err) expected := []dbtypes.DepositRow{ - dbtypes.NewDepositRow(1, depositor.String(), dbtypes.NewDbCoins(amount), 10), - dbtypes.NewDepositRow(1, depositor2.String(), dbtypes.NewDbCoins(amount2), 10), - dbtypes.NewDepositRow(1, depositor3.String(), dbtypes.NewDbCoins(amount3), 10), + dbtypes.NewDepositRow(1, depositor.String(), dbtypes.NewDbCoins(amount), timestamp1, 10), + dbtypes.NewDepositRow(1, depositor2.String(), dbtypes.NewDbCoins(amount2), timestamp2, 10), + dbtypes.NewDepositRow(1, depositor3.String(), dbtypes.NewDbCoins(amount3), timestamp3, 10), } var result []dbtypes.DepositRow err = suite.database.Sqlx.Select(&result, `SELECT * FROM proposal_deposit`) @@ -377,9 +381,9 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveDeposits() { amount3 = sdk.NewCoins(sdk.NewCoin("desmos", sdk.NewInt(30))) deposit = []types.Deposit{ - types.NewDeposit(proposal.ProposalID, depositor.String(), amount, 9), - types.NewDeposit(proposal.ProposalID, depositor2.String(), amount2, 10), - types.NewDeposit(proposal.ProposalID, depositor3.String(), amount3, 11), + types.NewDeposit(proposal.ProposalID, depositor.String(), amount, timestamp1, 9), + types.NewDeposit(proposal.ProposalID, depositor2.String(), amount2, timestamp2, 10), + types.NewDeposit(proposal.ProposalID, depositor3.String(), amount3, timestamp3, 11), } err = suite.database.SaveDeposits(deposit) @@ -387,9 +391,9 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveDeposits() { expected = []dbtypes.DepositRow{ dbtypes.NewDepositRow(1, depositor.String(), dbtypes.NewDbCoins( - sdk.NewCoins(sdk.NewCoin("desmos", sdk.NewInt(10000)))), 10), - dbtypes.NewDepositRow(1, depositor2.String(), dbtypes.NewDbCoins(amount2), 10), - dbtypes.NewDepositRow(1, depositor3.String(), dbtypes.NewDbCoins(amount3), 11), + sdk.NewCoins(sdk.NewCoin("desmos", sdk.NewInt(10000)))), timestamp1, 10), + dbtypes.NewDepositRow(1, depositor2.String(), dbtypes.NewDbCoins(amount2), timestamp2, 10), + dbtypes.NewDepositRow(1, depositor3.String(), dbtypes.NewDbCoins(amount3), timestamp3, 11), } result = []dbtypes.DepositRow{} @@ -410,11 +414,13 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveVote() { proposal := suite.getProposalRow(1) voter := suite.getAccount("cosmos1z4hfrxvlgl4s8u4n5ngjcw8kdqrcv43599amxs") - vote := types.NewVote(1, voter.String(), govtypes.OptionYes, 1) + timestamp := time.Date(2020, 1, 1, 15, 00, 00, 000, time.UTC) + + vote := types.NewVote(1, voter.String(), govtypes.OptionYes, timestamp, 1) err := suite.database.SaveVote(vote) suite.Require().NoError(err) - expected := dbtypes.NewVoteRow(int64(proposal.ProposalID), voter.String(), govtypes.OptionYes.String(), 1) + expected := dbtypes.NewVoteRow(int64(proposal.ProposalID), voter.String(), govtypes.OptionYes.String(), timestamp, 1) var result []dbtypes.VoteRow err = suite.database.Sqlx.Select(&result, `SELECT * FROM proposal_vote`) @@ -423,7 +429,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveVote() { suite.Require().True(expected.Equals(result[0])) // Update with lower height should not change option - vote = types.NewVote(1, voter.String(), govtypes.OptionNo, 0) + vote = types.NewVote(1, voter.String(), govtypes.OptionNo, timestamp, 0) err = suite.database.SaveVote(vote) suite.Require().NoError(err) @@ -434,11 +440,11 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveVote() { suite.Require().True(expected.Equals(result[0])) // Update with same height should change option - vote = types.NewVote(1, voter.String(), govtypes.OptionAbstain, 1) + vote = types.NewVote(1, voter.String(), govtypes.OptionAbstain, timestamp, 1) err = suite.database.SaveVote(vote) suite.Require().NoError(err) - expected = dbtypes.NewVoteRow(int64(proposal.ProposalID), voter.String(), govtypes.OptionAbstain.String(), 1) + expected = dbtypes.NewVoteRow(int64(proposal.ProposalID), voter.String(), govtypes.OptionAbstain.String(), timestamp, 1) result = []dbtypes.VoteRow{} err = suite.database.Sqlx.Select(&result, `SELECT * FROM proposal_vote`) @@ -447,11 +453,11 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveVote() { suite.Require().True(expected.Equals(result[0])) // Update with higher height should change option - vote = types.NewVote(1, voter.String(), govtypes.OptionNoWithVeto, 2) + vote = types.NewVote(1, voter.String(), govtypes.OptionNoWithVeto, timestamp, 2) err = suite.database.SaveVote(vote) suite.Require().NoError(err) - expected = dbtypes.NewVoteRow(int64(proposal.ProposalID), voter.String(), govtypes.OptionNoWithVeto.String(), 2) + expected = dbtypes.NewVoteRow(int64(proposal.ProposalID), voter.String(), govtypes.OptionNoWithVeto.String(), timestamp, 2) result = []dbtypes.VoteRow{} err = suite.database.Sqlx.Select(&result, `SELECT * FROM proposal_vote`) diff --git a/database/schema/08-gov.sql b/database/schema/08-gov.sql index df2ce5c2b..3df6f7598 100644 --- a/database/schema/08-gov.sql +++ b/database/schema/08-gov.sql @@ -30,7 +30,8 @@ CREATE TABLE proposal_deposit proposal_id INTEGER NOT NULL REFERENCES proposal (id), depositor_address TEXT REFERENCES account (address), amount COIN[], - height BIGINT NOT NULL REFERENCES block (height), + timestamp TIMESTAMP, + height BIGINT NOT NULL, CONSTRAINT unique_deposit UNIQUE (proposal_id, depositor_address) ); CREATE INDEX proposal_deposit_proposal_id_index ON proposal_deposit (proposal_id); @@ -42,7 +43,8 @@ CREATE TABLE proposal_vote proposal_id INTEGER NOT NULL REFERENCES proposal (id), voter_address TEXT NOT NULL REFERENCES account (address), option TEXT NOT NULL, - height BIGINT NOT NULL REFERENCES block (height), + timestamp TIMESTAMP, + height BIGINT NOT NULL, CONSTRAINT unique_vote UNIQUE (proposal_id, voter_address) ); CREATE INDEX proposal_vote_proposal_id_index ON proposal_vote (proposal_id); diff --git a/database/types/gov.go b/database/types/gov.go index 6efd5e580..3b6ad0646 100644 --- a/database/types/gov.go +++ b/database/types/gov.go @@ -118,10 +118,11 @@ func (w TallyResultRow) Equals(v TallyResultRow) bool { // VoteRow represents a single row inside the vote table type VoteRow struct { - Voter string `db:"voter_address"` - Option string `db:"option"` - ProposalID int64 `db:"proposal_id"` - Height int64 `db:"height"` + ProposalID int64 `db:"proposal_id"` + Voter string `db:"voter_address"` + Option string `db:"option"` + Timestamp time.Time `db:"timestamp"` + Height int64 `db:"height"` } // NewVoteRow allows to easily create a new VoteRow @@ -129,12 +130,14 @@ func NewVoteRow( proposalID int64, voter string, option string, + timestamp time.Time, height int64, ) VoteRow { return VoteRow{ ProposalID: proposalID, Voter: voter, Option: option, + Timestamp: timestamp, Height: height, } } @@ -144,15 +147,17 @@ func (w VoteRow) Equals(v VoteRow) bool { return w.ProposalID == v.ProposalID && w.Voter == v.Voter && w.Option == v.Option && + w.Timestamp.Equal(v.Timestamp) && w.Height == v.Height } // DepositRow represents a single row inside the deposit table type DepositRow struct { - Depositor string `db:"depositor_address"` - Amount DbCoins `db:"amount"` - ProposalID int64 `db:"proposal_id"` - Height int64 `db:"height"` + ProposalID int64 `db:"proposal_id"` + Depositor string `db:"depositor_address"` + Amount DbCoins `db:"amount"` + Timestamp time.Time `db:"timestamp"` + Height int64 `db:"height"` } // NewDepositRow allows to easily create a new NewDepositRow @@ -160,12 +165,14 @@ func NewDepositRow( proposalID int64, depositor string, amount DbCoins, + timestamp time.Time, height int64, ) DepositRow { return DepositRow{ ProposalID: proposalID, Depositor: depositor, Amount: amount, + Timestamp: timestamp, Height: height, } } @@ -175,6 +182,7 @@ func (w DepositRow) Equals(v DepositRow) bool { return w.ProposalID == v.ProposalID && w.Depositor == v.Depositor && w.Amount.Equal(&v.Amount) && + w.Timestamp.Equal(v.Timestamp) && w.Height == v.Height } diff --git a/hasura/metadata/databases/bdjuno/tables/public_account.yaml b/hasura/metadata/databases/bdjuno/tables/public_account.yaml index f3954d25c..a4ccc1e35 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_account.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_account.yaml @@ -49,8 +49,9 @@ array_relationships: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - address filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_from_genesis.yaml b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_from_genesis.yaml index ba555d57b..8624aa1fe 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_from_genesis.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_from_genesis.yaml @@ -3,9 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - average_time - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_day.yaml b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_day.yaml index 26fe01b50..c3c9ccbcf 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_day.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_day.yaml @@ -3,9 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - average_time - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_hour.yaml b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_hour.yaml index 75a957db9..640c64115 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_hour.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_hour.yaml @@ -3,9 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - average_time - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_minute.yaml b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_minute.yaml index 465f6454a..cdb7dae58 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_minute.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_minute.yaml @@ -3,9 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - average_time - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_block.yaml b/hasura/metadata/databases/bdjuno/tables/public_block.yaml index 5c3f15fc2..cfcf1258a 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_block.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_block.yaml @@ -51,7 +51,7 @@ array_relationships: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - num_txs - height @@ -60,4 +60,5 @@ select_permissions: - proposer_address - timestamp filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml b/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml index 21006960d..ca90c6278 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml @@ -3,9 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - coins - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml index ca0ecf723..fda0c9ca6 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml @@ -3,10 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - one_row_id - params - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml b/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml index 009da39c3..5bf4acf75 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml @@ -10,18 +10,11 @@ object_relationships: foreign_key_constraint_on: vote_b_id select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - height - vote_a_id - vote_b_id filter: {} + limit: 100 role: anonymous -- permission: - allow_aggregations: true - columns: - - height - - vote_a_id - - vote_b_id - filter: {} - role: client diff --git a/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml b/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml index 03f6217a7..658055f11 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml @@ -22,9 +22,8 @@ array_relationships: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - id - type - height - round @@ -33,17 +32,5 @@ select_permissions: - validator_index - signature filter: {} + limit: 100 role: anonymous -- permission: - allow_aggregations: true - columns: - - id - - type - - height - - round - - block_id - - validator_address - - validator_index - - signature - filter: {} - role: client diff --git a/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml b/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml index dc3ef472c..8b5359bc8 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml @@ -10,12 +10,12 @@ object_relationships: foreign_key_constraint_on: granter_address select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - id - grantee_address - granter_address - allowance - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml b/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml index c51e829af..73b0c7014 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml @@ -3,18 +3,11 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - chain_id - initial_height - time filter: {} - role: anonymous -- permission: - allow_aggregations: true - columns: - - chain_id - - one_row_id - - time - filter: {} - role: client + limit: 1 + role: anonymous \ No newline at end of file diff --git a/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml index 358c3e92d..37de9f06d 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml @@ -3,12 +3,12 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - one_row_id - deposit_params - voting_params - tally_params - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml b/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml index 2a348c863..b83e4f86d 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml @@ -3,15 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - value - height filter: {} + limit: 1 role: anonymous -- permission: - allow_aggregations: true - columns: - - height - filter: {} - role: client diff --git a/hasura/metadata/databases/bdjuno/tables/public_message.yaml b/hasura/metadata/databases/bdjuno/tables/public_message.yaml index aa572e712..fe6a4c31a 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_message.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_message.yaml @@ -13,14 +13,14 @@ object_relationships: transaction_hash: hash select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - transaction_hash - index - type - value - involved_accounts_addresses - - partition_id - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml index 948bcdc19..ee302f719 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml @@ -3,10 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - one_row_id - params - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_modules.yaml b/hasura/metadata/databases/bdjuno/tables/public_modules.yaml index 6ebde2ec2..1f5ec1e24 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_modules.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_modules.yaml @@ -3,8 +3,9 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - module_name filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml b/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml index e97a6db73..886d56e38 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml @@ -15,14 +15,5 @@ select_permissions: - voting_power - proposer_priority filter: {} - role: anonymous -- permission: - allow_aggregations: true - columns: - - validator_address - - height - - timestamp - - voting_power - - proposer_priority - filter: {} - role: client + limit: 100 + role: anonymous \ No newline at end of file diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml index aeaa47b29..491202cce 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml @@ -69,4 +69,5 @@ select_permissions: - status - content filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml index 7c480ff89..01e208c16 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml @@ -19,11 +19,13 @@ object_relationships: foreign_key_constraint_on: proposal_id select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - proposal_id - depositor_address - amount + - timestamp - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_staking_pool_snapshot.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_staking_pool_snapshot.yaml index 3f03cced1..6c9fe014f 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_staking_pool_snapshot.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_staking_pool_snapshot.yaml @@ -7,11 +7,12 @@ object_relationships: foreign_key_constraint_on: proposal_id select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - proposal_id - bonded_tokens - not_bonded_tokens - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml index e2e21c5f0..451d91e07 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml @@ -7,7 +7,7 @@ object_relationships: foreign_key_constraint_on: proposal_id select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - proposal_id - yes @@ -16,4 +16,5 @@ select_permissions: - no_with_veto - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_validator_status_snapshot.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_validator_status_snapshot.yaml index 769e27f3f..6869f9a36 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_validator_status_snapshot.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_validator_status_snapshot.yaml @@ -10,9 +10,8 @@ object_relationships: foreign_key_constraint_on: validator_address select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - id - proposal_id - validator_address - voting_power @@ -20,4 +19,5 @@ select_permissions: - jailed - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml index 30b70e033..60f3694be 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml @@ -7,17 +7,25 @@ object_relationships: foreign_key_constraint_on: voter_address - name: block using: - foreign_key_constraint_on: height + manual_configuration: + column_mapping: + height: height + insertion_order: null + remote_table: + name: block + schema: public - name: proposal using: foreign_key_constraint_on: proposal_id select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - proposal_id - voter_address - option + - timestamp - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml index 4969d9e28..912e8fc66 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml @@ -3,10 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - one_row_id - params - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml index be4455520..2cb4e10c7 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml @@ -3,10 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - one_row_id - params - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml b/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml index 0f7c65e9e..2c4ef61e5 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml @@ -3,7 +3,7 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - height - bonded_tokens @@ -11,4 +11,5 @@ select_permissions: - unbonding_tokens - staked_not_bonded_tokens filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_supply.yaml b/hasura/metadata/databases/bdjuno/tables/public_supply.yaml index 7e748d713..8f278c980 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_supply.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_supply.yaml @@ -3,9 +3,10 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - coins - height filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_token.yaml b/hasura/metadata/databases/bdjuno/tables/public_token.yaml index efb055e4f..e1b4a746a 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token.yaml @@ -11,8 +11,9 @@ array_relationships: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - name filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml b/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml index e28c7abbe..7c2a1fa0b 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml @@ -7,12 +7,12 @@ object_relationships: foreign_key_constraint_on: unit_name select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - id - unit_name - price - market_cap - timestamp filter: {} + limit: 1 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml b/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml index 45a771365..809f0a170 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml @@ -7,11 +7,12 @@ object_relationships: foreign_key_constraint_on: unit_name select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - market_cap - price - timestamp - unit_name filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml b/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml index 6b11f8186..cd30c03f4 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml @@ -31,7 +31,7 @@ array_relationships: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - aliases - denom @@ -39,4 +39,5 @@ select_permissions: - price_id - token_name filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml b/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml index 8cd83c738..df1e20fe1 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml @@ -7,7 +7,7 @@ object_relationships: foreign_key_constraint_on: height select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - hash - height @@ -21,6 +21,6 @@ select_permissions: - gas_used - raw_log - logs - - partition_id filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator.yaml index a2fbf8116..b4eac1c63 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator.yaml @@ -95,9 +95,10 @@ array_relationships: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - consensus_address - consensus_pubkey filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml index bbe8d3a6c..17a916133 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml @@ -7,11 +7,12 @@ object_relationships: foreign_key_constraint_on: validator_address select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - validator_address - commission - min_self_delegation - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml index 3edb4f67c..ca95d9400 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml @@ -7,7 +7,7 @@ object_relationships: foreign_key_constraint_on: validator_address select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - validator_address - moniker @@ -18,4 +18,5 @@ select_permissions: - height - avatar_url filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml index fb8d8b4e2..0979040eb 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml @@ -10,7 +10,7 @@ object_relationships: foreign_key_constraint_on: consensus_address select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - consensus_address - operator_address @@ -18,4 +18,5 @@ select_permissions: - max_change_rate - max_rate filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml index dba8155f3..8040e8a26 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml @@ -3,7 +3,7 @@ table: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - validator_address - start_height @@ -13,4 +13,5 @@ select_permissions: - missed_blocks_counter - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml index eeee00e6a..32f212d54 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml @@ -14,4 +14,5 @@ select_permissions: - jailed - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml index 6710ad5c4..fc5f76302 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml @@ -16,4 +16,5 @@ select_permissions: - voting_power - height filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml b/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml index 1b095315f..aba91ce74 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml @@ -15,13 +15,13 @@ array_relationships: schema: public select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - id - type - address - original_vesting - end_time - start_time filter: {} + limit: 100 role: anonymous diff --git a/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml b/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml index dc4de32cf..f56da44ac 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml @@ -7,11 +7,11 @@ object_relationships: foreign_key_constraint_on: vesting_account_id select_permissions: - permission: - allow_aggregations: true + allow_aggregations: false columns: - - vesting_account_id - period_order - length - amount filter: {} + limit: 100 role: anonymous diff --git a/modules/actions/config.go b/modules/actions/config.go index 47a5994e8..d127ed058 100644 --- a/modules/actions/config.go +++ b/modules/actions/config.go @@ -7,21 +7,24 @@ import ( // Config contains the configuration about the actions module type Config struct { - Node *remote.Details `yaml:"node,omitempty"` + Host string `yaml:"host"` Port uint `yaml:"port"` + Node *remote.Details `yaml:"node,omitempty"` } // NewConfig returns a new Config instance -func NewConfig(port uint, remoteDetails *remote.Details) *Config { +func NewConfig(host string, port uint, remoteDetails *remote.Details) *Config { return &Config{ + Host: host, Port: port, Node: remoteDetails, } } // DefaultConfig returns the default configuration -func DefaultConfig() Config { - return Config{ +func DefaultConfig() *Config { + return &Config{ + Host: "127.0.0.1", Port: 3000, Node: nil, } @@ -33,5 +36,10 @@ func ParseConfig(bz []byte) (*Config, error) { } var cfg T err := yaml.Unmarshal(bz, &cfg) + + if cfg.Config == nil { + return DefaultConfig(), nil + } + return cfg.Config, err } diff --git a/modules/actions/handle_additional_operations.go b/modules/actions/handle_additional_operations.go index de5a87369..69262a977 100644 --- a/modules/actions/handle_additional_operations.go +++ b/modules/actions/handle_additional_operations.go @@ -44,7 +44,7 @@ func (m *Module) RunAdditionalOperations() error { // Start the worker waitGroup.Add(1) - go worker.Start(m.cfg.Port) + go worker.Start(m.cfg.Host, m.cfg.Port) // Block main process (signal capture will call WaitGroup's Done) waitGroup.Wait() diff --git a/modules/actions/types/worker.go b/modules/actions/types/worker.go index ee849a0bf..6ae9b864d 100644 --- a/modules/actions/types/worker.go +++ b/modules/actions/types/worker.go @@ -94,7 +94,7 @@ func (w *ActionsWorker) handleError(writer http.ResponseWriter, path string, err } // Start starts the worker -func (w *ActionsWorker) Start(port uint) { +func (w *ActionsWorker) Start(host string, port uint) { server := &http.Server{ Addr: fmt.Sprintf(":%d", port), Handler: w.mux, @@ -104,7 +104,8 @@ func (w *ActionsWorker) Start(port uint) { IdleTimeout: time.Second * 30, } - if err := server.ListenAndServe(); err != nil { + err := server.ListenAndServe() + if err != nil { panic(err) } } diff --git a/modules/gov/handle_genesis.go b/modules/gov/handle_genesis.go index a0e74e1d7..d362db191 100644 --- a/modules/gov/handle_genesis.go +++ b/modules/gov/handle_genesis.go @@ -24,7 +24,7 @@ func (m *Module) HandleGenesis(doc *tmtypes.GenesisDoc, appState map[string]json } // Save the proposals - err = m.saveProposals(genState.Proposals, doc.InitialHeight) + err = m.saveProposals(genState.Proposals, doc) if err != nil { return fmt.Errorf("error while storing genesis governance proposals: %s", err) } @@ -44,7 +44,7 @@ func (m *Module) HandleGenesis(doc *tmtypes.GenesisDoc, appState map[string]json } // saveProposals save proposals from genesis file -func (m *Module) saveProposals(slice govtypes.Proposals, genHeight int64) error { +func (m *Module) saveProposals(slice govtypes.Proposals, genDoc *tmtypes.GenesisDoc) error { proposals := make([]types.Proposal, len(slice)) tallyResults := make([]types.TallyResult, len(slice)) deposits := make([]types.Deposit, len(slice)) @@ -70,14 +70,15 @@ func (m *Module) saveProposals(slice govtypes.Proposals, genHeight int64) error proposal.FinalTallyResult.Abstain.String(), proposal.FinalTallyResult.No.String(), proposal.FinalTallyResult.NoWithVeto.String(), - genHeight, + genDoc.InitialHeight, ) deposits[index] = types.NewDeposit( proposal.ProposalId, "", proposal.TotalDeposit, - genHeight, + genDoc.GenesisTime, + genDoc.InitialHeight, ) } diff --git a/modules/gov/handle_msg.go b/modules/gov/handle_msg.go index 0b4a88078..ce5c72a71 100644 --- a/modules/gov/handle_msg.go +++ b/modules/gov/handle_msg.go @@ -2,6 +2,8 @@ package gov import ( "fmt" + "time" + "strconv" "github.com/forbole/bdjuno/v3/types" @@ -73,8 +75,13 @@ func (m *Module) handleMsgSubmitProposal(tx *juno.Tx, index int, msg *govtypes.M return err } + txTimestamp, err := time.Parse(time.RFC3339, tx.Timestamp) + if err != nil { + return fmt.Errorf("error while parsing time: %s", err) + } + // Store the deposit - deposit := types.NewDeposit(proposal.ProposalId, msg.Proposer, msg.InitialDeposit, tx.Height) + deposit := types.NewDeposit(proposal.ProposalId, msg.Proposer, msg.InitialDeposit, txTimestamp, tx.Height) return m.db.SaveDeposits([]types.Deposit{deposit}) } @@ -85,13 +92,24 @@ func (m *Module) handleMsgDeposit(tx *juno.Tx, msg *govtypes.MsgDeposit) error { return fmt.Errorf("error while getting proposal deposit: %s", err) } + txTimestamp, err := time.Parse(time.RFC3339, tx.Timestamp) + if err != nil { + return fmt.Errorf("error while parsing time: %s", err) + } + return m.db.SaveDeposits([]types.Deposit{ - types.NewDeposit(msg.ProposalId, msg.Depositor, deposit.Amount, tx.Height), + types.NewDeposit(msg.ProposalId, msg.Depositor, deposit.Amount, txTimestamp, tx.Height), }) } // handleMsgVote allows to properly handle a handleMsgVote func (m *Module) handleMsgVote(tx *juno.Tx, msg *govtypes.MsgVote) error { - vote := types.NewVote(msg.ProposalId, msg.Voter, msg.Option, tx.Height) + txTimestamp, err := time.Parse(time.RFC3339, tx.Timestamp) + if err != nil { + return fmt.Errorf("error while parsing time: %s", err) + } + + vote := types.NewVote(msg.ProposalId, msg.Voter, msg.Option, txTimestamp, tx.Height) + return m.db.SaveVote(vote) } diff --git a/types/config/config.go b/types/config/config.go index 187c22269..fb7127182 100644 --- a/types/config/config.go +++ b/types/config/config.go @@ -11,12 +11,12 @@ import ( // Config represents the BDJuno configuration type Config struct { + ActionsConfig *actions.Config `yaml:"actions"` JunoConfig junoconfig.Config `yaml:"-,inline"` - ActionsConfig actions.Config `yaml:"actions"` } // NewConfig returns a new Config instance -func NewConfig(junoCfg junoconfig.Config, actionsCfg actions.Config) Config { +func NewConfig(junoCfg junoconfig.Config, actionsCfg *actions.Config) Config { return Config{ JunoConfig: junoCfg, ActionsConfig: actionsCfg, diff --git a/types/gov.go b/types/gov.go index 04aded732..4e26108d3 100644 --- a/types/gov.go +++ b/types/gov.go @@ -4,7 +4,6 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -153,9 +152,10 @@ func NewProposalUpdate( // Deposit contains the data of a single deposit made towards a proposal type Deposit struct { + ProposalID uint64 Depositor string Amount sdk.Coins - ProposalID uint64 + Timestamp time.Time Height int64 } @@ -164,12 +164,14 @@ func NewDeposit( proposalID uint64, depositor string, amount sdk.Coins, + timestamp time.Time, height int64, ) Deposit { return Deposit{ ProposalID: proposalID, Depositor: depositor, Amount: amount, + Timestamp: timestamp, Height: height, } } @@ -178,10 +180,11 @@ func NewDeposit( // Vote contains the data of a single proposal vote type Vote struct { - Voter string ProposalID uint64 - Height int64 + Voter string Option govtypes.VoteOption + Timestamp time.Time + Height int64 } // NewVote return a new Vote instance @@ -189,12 +192,14 @@ func NewVote( proposalID uint64, voter string, option govtypes.VoteOption, + timestamp time.Time, height int64, ) Vote { return Vote{ ProposalID: proposalID, Voter: voter, Option: option, + Timestamp: timestamp, Height: height, } }