diff --git a/database/gov.go b/database/gov.go index f8c22ea5d..b8ee30349 100644 --- a/database/gov.go +++ b/database/gov.go @@ -284,17 +284,20 @@ WHERE proposal_deposit.height <= excluded.height` } // -------------------------------------------------------------------------------------------------------------------- +func (db *Db) CleanVote(proposal_id uint64, voter string) error { + flagQuery := `UPDATE proposal_vote SET is_valid=FALSE WHERE proposal_id=$1 AND voter_address=$2` + _, err := db.SQL.Exec(flagQuery, proposal_id, voter) + if err != nil { + return fmt.Errorf("error while updating past vote: %s", err) + } + return nil +} // 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, 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` +INSERT INTO proposal_vote (proposal_id, voter_address, is_valid, option, weight, timestamp, height) +VALUES ($1, $2, TRUE, $3, $4, $5, $6)` // Store the voter account err := db.SaveAccounts([]types.Account{types.NewAccount(vote.Voter)}) @@ -302,7 +305,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.Timestamp, vote.Height) + _, err = db.SQL.Exec(query, vote.ProposalID, vote.Voter, vote.Option.String(), vote.Weight, vote.Timestamp, vote.Height) if err != nil { return fmt.Errorf("error while storing vote: %s", err) } @@ -332,14 +335,6 @@ func (db *Db) SaveTallyResults(tallys []types.TallyResult) error { } query = query[:len(query)-1] // Remove trailing "," - query += ` -ON CONFLICT ON CONSTRAINT unique_tally_result DO UPDATE - SET yes = excluded.yes, - abstain = excluded.abstain, - no = excluded.no, - no_with_veto = excluded.no_with_veto, - height = excluded.height -WHERE proposal_tally_result.height <= excluded.height` _, err := db.SQL.Exec(query, param...) if err != nil { return fmt.Errorf("error while storing tally result: %s", err) @@ -354,13 +349,7 @@ WHERE proposal_tally_result.height <= excluded.height` func (db *Db) SaveProposalStakingPoolSnapshot(snapshot types.ProposalStakingPoolSnapshot) error { stmt := ` INSERT INTO proposal_staking_pool_snapshot (proposal_id, bonded_tokens, not_bonded_tokens, height) -VALUES ($1, $2, $3, $4) -ON CONFLICT ON CONSTRAINT unique_staking_pool_snapshot DO UPDATE SET - proposal_id = excluded.proposal_id, - bonded_tokens = excluded.bonded_tokens, - not_bonded_tokens = excluded.not_bonded_tokens, - height = excluded.height -WHERE proposal_staking_pool_snapshot.height <= excluded.height` +VALUES ($1, $2, $3, $4)` _, err := db.SQL.Exec(stmt, snapshot.ProposalID, snapshot.Pool.BondedTokens.String(), snapshot.Pool.NotBondedTokens.String(), snapshot.Pool.Height) @@ -392,15 +381,6 @@ VALUES ` } stmt = stmt[:len(stmt)-1] - stmt += ` -ON CONFLICT ON CONSTRAINT unique_validator_status_snapshot DO UPDATE - SET proposal_id = excluded.proposal_id, - validator_address = excluded.validator_address, - voting_power = excluded.voting_power, - status = excluded.status, - jailed = excluded.jailed, - height = excluded.height -WHERE proposal_validator_status_snapshot.height <= excluded.height` _, err := db.SQL.Exec(stmt, args...) if err != nil { return fmt.Errorf("error while storing proposal validator statuses snapshot: %s", err) diff --git a/database/gov_test.go b/database/gov_test.go index 89b54d6d0..970f440d7 100644 --- a/database/gov_test.go +++ b/database/gov_test.go @@ -12,8 +12,8 @@ import ( "github.com/forbole/bdjuno/v4/types" - sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/atomone-hub/govgen/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" dbtypes "github.com/forbole/bdjuno/v4/database/types" ) @@ -84,10 +84,10 @@ func (suite *DbTestSuite) getProposalRow(id int) types.Proposal { proposalType, govtypes.NewTextProposal(title, description), govtypes.StatusPassed.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer.String(), ) @@ -123,10 +123,10 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "proposalType", content1, govtypes.StatusDepositPeriod.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer1.String(), ), types.NewProposal( @@ -135,10 +135,10 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "proposalType1", content2, govtypes.StatusPassed.String(), - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), ), } @@ -158,10 +158,10 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "title", "description", suite.encodeProposalContent(content1), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer1.String(), govtypes.StatusDepositPeriod.String(), ), @@ -172,10 +172,10 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "title1", "description1", suite.encodeProposalContent(content2), - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), govtypes.StatusPassed.String(), ), @@ -194,10 +194,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetProposal() { "proposalType", content, govtypes.StatusDepositPeriod.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer.String(), ) input := []types.Proposal{proposal} @@ -223,10 +223,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType1", content2, types.ProposalStatusInvalid, - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), ) @@ -237,10 +237,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType", content1, govtypes.StatusVotingPeriod.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer1.String(), ), types.NewProposal( @@ -249,10 +249,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType", content1, govtypes.StatusDepositPeriod.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer1.String(), ), types.NewProposal( @@ -261,10 +261,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType1", content2, govtypes.StatusPassed.String(), - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), ), types.NewProposal( @@ -273,10 +273,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType1", content2, govtypes.StatusRejected.String(), - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), ), invalidProposal, @@ -299,8 +299,8 @@ func (suite *DbTestSuite) TestBigDipperDb_UpdateProposal() { update := types.NewProposalUpdate( proposal.ProposalID, govtypes.StatusPassed.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), ) err = suite.database.UpdateProposal(update) @@ -315,8 +315,8 @@ func (suite *DbTestSuite) TestBigDipperDb_UpdateProposal() { suite.encodeProposalContent(proposal.Content), proposal.SubmitTime, proposal.DepositEndTime, - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), proposer.String(), govtypes.StatusPassed.String(), ) @@ -348,9 +348,9 @@ 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) + timestamp1 := time.Date(2020, 1, 1, 15, 0o0, 0o0, 0o00, time.UTC) + timestamp2 := time.Date(2020, 1, 1, 16, 0o0, 0o0, 0o00, time.UTC) + timestamp3 := time.Date(2020, 1, 1, 17, 0o0, 0o0, 0o00, time.UTC) deposit := []types.Deposit{ types.NewDeposit(proposal.ProposalID, depositor.String(), amount, timestamp1, 10), @@ -414,9 +414,9 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveVote() { proposal := suite.getProposalRow(1) voter := suite.getAccount("cosmos1z4hfrxvlgl4s8u4n5ngjcw8kdqrcv43599amxs") - timestamp := time.Date(2020, 1, 1, 15, 00, 00, 000, time.UTC) + timestamp := time.Date(2020, 1, 1, 15, 0o0, 0o0, 0o00, time.UTC) - vote := types.NewVote(1, voter.String(), govtypes.OptionYes, timestamp, 1) + vote := types.NewVote(1, voter.String(), govtypes.OptionYes, "1.0", timestamp, 1) err := suite.database.SaveVote(vote) suite.Require().NoError(err) @@ -429,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, timestamp, 0) + vote = types.NewVote(1, voter.String(), govtypes.OptionNo, "1.0", timestamp, 0) err = suite.database.SaveVote(vote) suite.Require().NoError(err) @@ -440,7 +440,7 @@ 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, timestamp, 1) + vote = types.NewVote(1, voter.String(), govtypes.OptionAbstain, "1.0", timestamp, 1) err = suite.database.SaveVote(vote) suite.Require().NoError(err) @@ -453,7 +453,7 @@ 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, timestamp, 2) + vote = types.NewVote(1, voter.String(), govtypes.OptionNoWithVeto, "1.0", timestamp, 2) err = suite.database.SaveVote(vote) suite.Require().NoError(err) @@ -631,7 +631,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposalValidatorsStatusesSnapshot // ---------------------------------------------------------------------------------------------------------------- // Save snapshots - var snapshots = []types.ProposalValidatorStatusSnapshot{ + snapshots := []types.ProposalValidatorStatusSnapshot{ types.NewProposalValidatorStatusSnapshot( 1, validator1.GetConsAddr(), @@ -830,7 +830,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveSoftwareUpgradePlan() { // ---------------------------------------------------------------------------------------------------------------- // Save software upgrade plan at height 10 with upgrade height at 100 - var plan = upgradetypes.Plan{ + plan := upgradetypes.Plan{ Name: "name", Height: 100, Info: "info", @@ -909,7 +909,7 @@ func (suite *DbTestSuite) TestBigDipperDb_DeleteSoftwareUpgradePlan() { _ = suite.getProposalRow(1) // Save software upgrade plan at height 10 with upgrade height at 100 - var plan = upgradetypes.Plan{ + plan := upgradetypes.Plan{ Name: "name", Height: 100, Info: "info", @@ -926,14 +926,13 @@ func (suite *DbTestSuite) TestBigDipperDb_DeleteSoftwareUpgradePlan() { err = suite.database.Sqlx.Select(&rows, `SELECT * FROM software_upgrade_plan`) suite.Require().NoError(err) suite.Require().Len(rows, 0) - } func (suite *DbTestSuite) TestBigDipperDb_CheckSoftwareUpgradePlan() { _ = suite.getProposalRow(1) // Save software upgrade plan at height 10 with upgrade height at 100 - var plan = upgradetypes.Plan{ + plan := upgradetypes.Plan{ Name: "name", // the Height here is the upgrade height Height: 100, diff --git a/database/schema/08-gov.sql b/database/schema/08-gov.sql index 3df6f7598..479fbde52 100644 --- a/database/schema/08-gov.sql +++ b/database/schema/08-gov.sql @@ -42,10 +42,11 @@ CREATE TABLE proposal_vote ( proposal_id INTEGER NOT NULL REFERENCES proposal (id), voter_address TEXT NOT NULL REFERENCES account (address), + is_valid BOOLEAN NOT NULL, option TEXT NOT NULL, + weight TEXT NOT NULL, timestamp TIMESTAMP, - height BIGINT NOT NULL, - CONSTRAINT unique_vote UNIQUE (proposal_id, voter_address) + height BIGINT NOT NULL ); CREATE INDEX proposal_vote_proposal_id_index ON proposal_vote (proposal_id); CREATE INDEX proposal_vote_voter_address_index ON proposal_vote (voter_address); @@ -53,24 +54,22 @@ CREATE INDEX proposal_vote_height_index ON proposal_vote (height); CREATE TABLE proposal_tally_result ( - proposal_id INTEGER REFERENCES proposal (id) PRIMARY KEY, + proposal_id INTEGER REFERENCES proposal (id), yes TEXT NOT NULL, abstain TEXT NOT NULL, no TEXT NOT NULL, no_with_veto TEXT NOT NULL, - height BIGINT NOT NULL, - CONSTRAINT unique_tally_result UNIQUE (proposal_id) + height BIGINT NOT NULL ); CREATE INDEX proposal_tally_result_proposal_id_index ON proposal_tally_result (proposal_id); CREATE INDEX proposal_tally_result_height_index ON proposal_tally_result (height); CREATE TABLE proposal_staking_pool_snapshot ( - proposal_id INTEGER REFERENCES proposal (id) PRIMARY KEY, + proposal_id INTEGER REFERENCES proposal (id), bonded_tokens TEXT NOT NULL, not_bonded_tokens TEXT NOT NULL, - height BIGINT NOT NULL, - CONSTRAINT unique_staking_pool_snapshot UNIQUE (proposal_id) + height BIGINT NOT NULL ); CREATE INDEX proposal_staking_pool_snapshot_proposal_id_index ON proposal_staking_pool_snapshot (proposal_id); @@ -82,8 +81,71 @@ CREATE TABLE proposal_validator_status_snapshot voting_power BIGINT NOT NULL, status INT NOT NULL, jailed BOOLEAN NOT NULL, - height BIGINT NOT NULL, - CONSTRAINT unique_validator_status_snapshot UNIQUE (proposal_id, validator_address) + height BIGINT NOT NULL ); CREATE INDEX proposal_validator_status_snapshot_proposal_id_index ON proposal_validator_status_snapshot (proposal_id); -CREATE INDEX proposal_validator_status_snapshot_validator_address_index ON proposal_validator_status_snapshot (validator_address); \ No newline at end of file +CREATE INDEX proposal_validator_status_snapshot_validator_address_index ON proposal_validator_status_snapshot (validator_address); + +CREATE OR REPLACE FUNCTION public.active_first(proposal_row proposal) + RETURNS integer + LANGUAGE sql + STABLE +AS $function$ +SELECT +CASE WHEN proposal_row.status='PROPOSAL_STATUS_PASSED' THEN 3 +WHEN proposal_row.status='PROPOSAL_STATUS_DEPOSIT_PERIOD' THEN 1 + WHEN proposal_row.status='PROPOSAL_STATUS_VOTING_PERIOD' THEN 2 + WHEN proposal_row.status='PROPOSAL_STATUS_REJECTED' THEN 4 + WHEN proposal_row.status='PROPOSAL_STATUS_FAILED' THEN 5 + WHEN proposal_row.status='PROPOSAL_STATUS_INVALID' THEN 6 +ELSE 7 +END +$function$ + +CREATE OR REPLACE FUNCTION public.failed_first(proposal_row proposal) + RETURNS integer + LANGUAGE sql + STABLE +AS $function$ +SELECT +CASE WHEN proposal_row.status='PROPOSAL_STATUS_PASSED' THEN 4 +WHEN proposal_row.status='PROPOSAL_STATUS_DEPOSIT_PERIOD' THEN 2 + WHEN proposal_row.status='PROPOSAL_STATUS_VOTING_PERIOD' THEN 3 + WHEN proposal_row.status='PROPOSAL_STATUS_REJECTED' THEN 5 + WHEN proposal_row.status='PROPOSAL_STATUS_FAILED' THEN 1 + WHEN proposal_row.status='PROPOSAL_STATUS_INVALID' THEN 6 +ELSE 7 +END +$function$ + +CREATE OR REPLACE FUNCTION public.passed_first(proposal_row proposal) + RETURNS integer + LANGUAGE sql + STABLE +AS $function$ +SELECT +CASE WHEN proposal_row.status='PROPOSAL_STATUS_PASSED' THEN 1 +WHEN proposal_row.status='PROPOSAL_STATUS_DEPOSIT_PERIOD' THEN 2 + WHEN proposal_row.status='PROPOSAL_STATUS_VOTING_PERIOD' THEN 3 + WHEN proposal_row.status='PROPOSAL_STATUS_REJECTED' THEN 4 + WHEN proposal_row.status='PROPOSAL_STATUS_FAILED' THEN 5 + WHEN proposal_row.status='PROPOSAL_STATUS_INVALID' THEN 6 +ELSE 7 +END +$function$ + +CREATE OR REPLACE FUNCTION public.rejected_first(proposal_row proposal) + RETURNS integer + LANGUAGE sql + STABLE +AS $function$ +SELECT +CASE WHEN proposal_row.status='PROPOSAL_STATUS_PASSED' THEN 4 +WHEN proposal_row.status='PROPOSAL_STATUS_DEPOSIT_PERIOD' THEN 2 + WHEN proposal_row.status='PROPOSAL_STATUS_VOTING_PERIOD' THEN 3 + WHEN proposal_row.status='PROPOSAL_STATUS_REJECTED' THEN 1 + WHEN proposal_row.status='PROPOSAL_STATUS_FAILED' THEN 5 + WHEN proposal_row.status='PROPOSAL_STATUS_INVALID' THEN 6 +ELSE 7 +END +$function$ \ No newline at end of file diff --git a/hasura/metadata/actions.graphql b/hasura/metadata/actions.graphql index 6a0346074..6a21cf08d 100644 --- a/hasura/metadata/actions.graphql +++ b/hasura/metadata/actions.graphql @@ -1,81 +1,103 @@ type Query { - action_account_balance( - address: String! - height: Int - ): ActionBalance - - action_delegation_reward( - address: String! - height: Int - ): [ActionDelegationReward] - - action_delegator_withdraw_address( - address: String! - ): ActionAddress! - - action_delegation( - address: String! - height: Int - offset: Int - limit: Int - count_total: Boolean - ): ActionDelegationResponse - - action_delegation_total( - address: String! - height: Int - ): ActionBalance - - action_redelegation( - address: String! - height: Int - offset: Int - limit: Int - count_total: Boolean - ): ActionRedelegationResponse - - action_unbonding_delegation( - address: String! - height: Int - offset: Int - limit: Int - count_total: Boolean - ): ActionUnbondingDelegationResponse - - action_unbonding_delegation_total( - address: String! - height: Int - ): ActionBalance - - action_validator_commission_amount( - address: String! - ): ActionValidatorCommissionAmount - - action_validator_delegations( - address: String! - offset: Int - limit: Int - count_total: Boolean - ): ActionDelegationResponse - - action_validator_redelegations_from( - address: String! - height: Int - offset: Int - limit: Int - count_total: Boolean - ): ActionRedelegationResponse - - action_validator_unbonding_delegations( - address: String! - offset: Int - limit: Int - count_total: Boolean - ): ActionUnbondingDelegationResponse + action_account_balance( + address: String! + height: Int + ): ActionBalance +} + +type Query { + action_delegation( + address: String! + height: Int + offset: Int + limit: Int + count_total: Boolean + ): ActionDelegationResponse +} + +type Query { + action_delegation_reward( + address: String! + height: Int + ): [ActionDelegationReward] +} + +type Query { + action_delegation_total( + address: String! + height: Int + ): ActionBalance +} + +type Query { + action_delegator_withdraw_address( + address: String! + ): ActionAddress! +} + +type Query { + action_redelegation( + address: String! + height: Int + offset: Int + limit: Int + count_total: Boolean + ): ActionRedelegationResponse +} + +type Query { + action_unbonding_delegation( + address: String! + height: Int + offset: Int + limit: Int + count_total: Boolean + ): ActionUnbondingDelegationResponse +} + +type Query { + action_unbonding_delegation_total( + address: String! + height: Int + ): ActionBalance +} + +type Query { + action_validator_commission_amount( + address: String! + ): ActionValidatorCommissionAmount +} + +type Query { + action_validator_delegations( + address: String! + offset: Int + limit: Int + count_total: Boolean + ): ActionDelegationResponse +} + +type Query { + action_validator_redelegations_from( + address: String! + height: Int + offset: Int + limit: Int + count_total: Boolean + ): ActionRedelegationResponse +} + +type Query { + action_validator_unbonding_delegations( + address: String! + offset: Int + limit: Int + count_total: Boolean + ): ActionUnbondingDelegationResponse } type ActionBalance { - coins: [ActionCoin] + coins: [ActionCoin] } type ActionDelegationReward { @@ -84,32 +106,37 @@ type ActionDelegationReward { } type ActionAddress { - address: String! + address: String! } type ActionDelegationResponse { - delegations: [ActionDelegation] - pagination: ActionPagination + delegations: [ActionDelegation] + pagination: ActionPagination } type ActionRedelegationResponse { - redelegations: [ActionRedelegation] - pagination: ActionPagination + redelegations: [ActionRedelegation] + pagination: ActionPagination } type ActionUnbondingDelegationResponse { - unbonding_delegations: [ActionUnbondingDelegation] - pagination: ActionPagination + unbonding_delegations: [ActionUnbondingDelegation] + pagination: ActionPagination } type ActionValidatorCommissionAmount { - coins: [ActionCoin] + coins: [ActionCoin] } scalar ActionCoin + scalar ActionDelegation + scalar ActionEntry + scalar ActionPagination + scalar ActionRedelegation + scalar ActionUnbondingDelegation diff --git a/hasura/metadata/api_limits.yaml b/hasura/metadata/api_limits.yaml new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/hasura/metadata/api_limits.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/backend_configs.yaml b/hasura/metadata/backend_configs.yaml new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/hasura/metadata/backend_configs.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/databases/bdjuno/tables/public_account.yaml b/hasura/metadata/databases/bdjuno/tables/public_account.yaml index a4ccc1e35..a437b8e0b 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_account.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_account.yaml @@ -2,56 +2,55 @@ table: name: account schema: public object_relationships: -- name: vesting_account - using: - manual_configuration: - column_mapping: - address: address - insertion_order: null - remote_table: - name: vesting_account - schema: public + - name: vesting_account + using: + manual_configuration: + column_mapping: + address: address + insertion_order: null + remote_table: + name: vesting_account + schema: public array_relationships: -- name: proposal_deposits - using: - foreign_key_constraint_on: - column: depositor_address - table: - name: proposal_deposit - schema: public -- name: proposal_votes - using: - foreign_key_constraint_on: - column: voter_address - table: - name: proposal_vote - schema: public -- name: proposals - using: - foreign_key_constraint_on: - column: proposer_address - table: - name: proposal - schema: public -- name: validator_infos - using: - foreign_key_constraint_on: - column: self_delegate_address - table: - name: validator_info - schema: public -- name: vesting_accounts - using: - foreign_key_constraint_on: - column: address - table: - name: vesting_account - schema: public + - name: proposal_deposits + using: + foreign_key_constraint_on: + column: depositor_address + table: + name: proposal_deposit + schema: public + - name: proposal_votes + using: + foreign_key_constraint_on: + column: voter_address + table: + name: proposal_vote + schema: public + - name: proposals + using: + foreign_key_constraint_on: + column: proposer_address + table: + name: proposal + schema: public + - name: validator_infos + using: + foreign_key_constraint_on: + column: self_delegate_address + table: + name: validator_info + schema: public + - name: vesting_accounts + using: + foreign_key_constraint_on: + column: address + table: + name: vesting_account + schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - address - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - address + filter: {} + limit: 100 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 8624aa1fe..d80ab32ed 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 @@ -2,11 +2,10 @@ table: name: average_block_time_from_genesis schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - average_time - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - average_time + - height + filter: {} + limit: 1 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 c3c9ccbcf..4958e9cb4 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 @@ -2,11 +2,10 @@ table: name: average_block_time_per_day schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - average_time - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - average_time + - height + filter: {} + limit: 1 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 640c64115..c225bb488 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 @@ -2,11 +2,10 @@ table: name: average_block_time_per_hour schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - average_time - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - average_time + - height + filter: {} + limit: 1 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 cdb7dae58..3e52b2283 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 @@ -2,11 +2,10 @@ table: name: average_block_time_per_minute schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - average_time - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - average_time + - height + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_block.yaml b/hasura/metadata/databases/bdjuno/tables/public_block.yaml index cfcf1258a..8f5d5fe0f 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_block.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_block.yaml @@ -2,63 +2,62 @@ table: name: block schema: public object_relationships: -- name: validator - using: - foreign_key_constraint_on: proposer_address + - name: validator + using: + foreign_key_constraint_on: proposer_address array_relationships: -- name: pre_commits - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: pre_commit - schema: public -- name: transactions - using: - foreign_key_constraint_on: - column: height - table: - name: transaction - schema: public -- name: validator_voting_powers - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: validator_voting_power - schema: public -- name: proposal_deposits - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: proposal_deposit - schema: public -- name: proposal_votes - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: proposal_vote - schema: public + - name: pre_commits + using: + manual_configuration: + column_mapping: + height: height + insertion_order: null + remote_table: + name: pre_commit + schema: public + - name: proposal_deposits + using: + manual_configuration: + column_mapping: + height: height + insertion_order: null + remote_table: + name: proposal_deposit + schema: public + - name: proposal_votes + using: + manual_configuration: + column_mapping: + height: height + insertion_order: null + remote_table: + name: proposal_vote + schema: public + - name: transactions + using: + foreign_key_constraint_on: + column: height + table: + name: transaction + schema: public + - name: validator_voting_powers + using: + manual_configuration: + column_mapping: + height: height + insertion_order: null + remote_table: + name: validator_voting_power + schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - num_txs - - height - - total_gas - - hash - - proposer_address - - timestamp - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - num_txs + - height + - total_gas + - hash + - proposer_address + - timestamp + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_ccv_consumer_chain.yaml b/hasura/metadata/databases/bdjuno/tables/public_ccv_consumer_chain.yaml index b393076a9..db72d084f 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_ccv_consumer_chain.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_ccv_consumer_chain.yaml @@ -2,15 +2,15 @@ table: name: ccv_consumer_chain schema: public select_permissions: -- permission: - allow_aggregations: true - columns: - - provider_client_id - - provider_channel_id - - chain_id - - provider_client_state - - provider_consensus_state - - initial_val_set - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - provider_client_id + - provider_channel_id + - chain_id + - provider_client_state + - provider_consensus_state + - initial_val_set + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_ccv_consumer_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_ccv_consumer_params.yaml index 9803e7fb2..d75c90ef2 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_ccv_consumer_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_ccv_consumer_params.yaml @@ -2,11 +2,11 @@ table: name: ccv_consumer_params schema: public select_permissions: -- permission: - allow_aggregations: true - columns: - - one_row_id - - params - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - one_row_id + - params + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_ccv_provider_chain.yaml b/hasura/metadata/databases/bdjuno/tables/public_ccv_provider_chain.yaml index faae67490..d1c294cd5 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_ccv_provider_chain.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_ccv_provider_chain.yaml @@ -2,19 +2,19 @@ table: name: ccv_provider_chain schema: public select_permissions: -- permission: - allow_aggregations: true - columns: - - valset_update_id - - consumer_states - - unbonding_ops - - mature_unbonding_ops - - valset_update_id_to_height - - consumer_addition_proposals - - consumer_removal_proposals - - validator_consumer_pubkeys - - validators_by_consumer_addr - - consumer_addrs_to_prune - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - valset_update_id + - consumer_states + - unbonding_ops + - mature_unbonding_ops + - valset_update_id_to_height + - consumer_addition_proposals + - consumer_removal_proposals + - validator_consumer_pubkeys + - validators_by_consumer_addr + - consumer_addrs_to_prune + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_ccv_provider_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_ccv_provider_params.yaml index 18b200996..934d0909c 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_ccv_provider_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_ccv_provider_params.yaml @@ -2,11 +2,11 @@ table: name: ccv_provider_params schema: public select_permissions: -- permission: - allow_aggregations: true - columns: - - one_row_id - - params - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - one_row_id + - params + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml b/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml index ca90c6278..d26c40156 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml @@ -2,11 +2,10 @@ table: name: community_pool schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - coins - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - coins + - height + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml index fda0c9ca6..b9f07926d 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml @@ -2,11 +2,10 @@ table: name: distribution_params schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - params - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - params + - height + filter: {} + limit: 1 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 5bf4acf75..ec6290d94 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml @@ -2,19 +2,18 @@ table: name: double_sign_evidence schema: public object_relationships: -- name: doubleSignVoteByVoteAId - using: - foreign_key_constraint_on: vote_a_id -- name: double_sign_vote - using: - foreign_key_constraint_on: vote_b_id + - name: doubleSignVoteByVoteAId + using: + foreign_key_constraint_on: vote_a_id + - name: double_sign_vote + using: + foreign_key_constraint_on: vote_b_id select_permissions: -- permission: - allow_aggregations: false - columns: - - height - - vote_a_id - - vote_b_id - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - height + - vote_a_id + - vote_b_id + filter: {} + limit: 100 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 658055f11..097cd997e 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml @@ -2,35 +2,34 @@ table: name: double_sign_vote schema: public object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address array_relationships: -- name: doubleSignEvidencesByVoteBId - using: - foreign_key_constraint_on: - column: vote_b_id - table: - name: double_sign_evidence - schema: public -- name: double_sign_evidences - using: - foreign_key_constraint_on: - column: vote_a_id - table: - name: double_sign_evidence - schema: public + - name: doubleSignEvidencesByVoteBId + using: + foreign_key_constraint_on: + column: vote_b_id + table: + name: double_sign_evidence + schema: public + - name: double_sign_evidences + using: + foreign_key_constraint_on: + column: vote_a_id + table: + name: double_sign_evidence + schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - type - - height - - round - - block_id - - validator_address - - validator_index - - signature - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - type + - height + - round + - block_id + - validator_address + - validator_index + - signature + filter: {} + limit: 100 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 8b5359bc8..63396f864 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml @@ -2,20 +2,19 @@ table: name: fee_grant_allowance schema: public object_relationships: -- name: grantee - using: - foreign_key_constraint_on: grantee_address -- name: granter - using: - foreign_key_constraint_on: granter_address + - name: grantee + using: + foreign_key_constraint_on: grantee_address + - name: granter + using: + foreign_key_constraint_on: granter_address select_permissions: -- permission: - allow_aggregations: false - columns: - - grantee_address - - granter_address - - allowance - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - grantee_address + - granter_address + - allowance + - height + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml b/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml index 73b0c7014..25bd6d6ee 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml @@ -2,12 +2,11 @@ table: name: genesis schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - chain_id - - initial_height - - time - filter: {} - limit: 1 - role: anonymous \ No newline at end of file + - role: anonymous + permission: + columns: + - chain_id + - initial_height + - time + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml index 37de9f06d..6f0ccc019 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml @@ -2,13 +2,12 @@ table: name: gov_params schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - deposit_params - - voting_params - - tally_params - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - deposit_params + - voting_params + - tally_params + - height + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml b/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml index b83e4f86d..5ffc3fc48 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml @@ -2,11 +2,10 @@ table: name: inflation schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - value - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - value + - height + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_message.yaml b/hasura/metadata/databases/bdjuno/tables/public_message.yaml index fe6a4c31a..083abcf77 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_message.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_message.yaml @@ -2,25 +2,24 @@ table: name: message schema: public object_relationships: -- name: transaction - using: - manual_configuration: - remote_table: - schema: public - name: transaction - insertion_order: - column_mapping: - transaction_hash: hash + - name: transaction + using: + manual_configuration: + column_mapping: + transaction_hash: hash + insertion_order: null + remote_table: + name: transaction + schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - transaction_hash - - index - - type - - value - - involved_accounts_addresses - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - transaction_hash + - index + - type + - value + - involved_accounts_addresses + - height + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml index ee302f719..b6f56eda0 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml @@ -2,11 +2,10 @@ table: name: mint_params schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - params - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - params + - height + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_modules.yaml b/hasura/metadata/databases/bdjuno/tables/public_modules.yaml index 1f5ec1e24..9f00706a4 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_modules.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_modules.yaml @@ -2,10 +2,9 @@ table: name: modules schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - module_name - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - module_name + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml b/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml index 886d56e38..24540e843 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml @@ -2,18 +2,18 @@ table: name: pre_commit schema: public object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - height - - timestamp - - voting_power - - proposer_priority - filter: {} - limit: 100 - role: anonymous \ No newline at end of file + - role: anonymous + permission: + columns: + - validator_address + - height + - timestamp + - voting_power + - proposer_priority + filter: {} + limit: 100 + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml index 491202cce..04de1fa26 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml @@ -2,72 +2,98 @@ table: name: proposal schema: public object_relationships: -- name: proposal_tally_result - using: - manual_configuration: - column_mapping: - id: proposal_id - insertion_order: null - remote_table: - name: proposal_tally_result - schema: public -- name: proposer - using: - foreign_key_constraint_on: proposer_address -- name: staking_pool_snapshot - using: - manual_configuration: - column_mapping: - id: proposal_id - insertion_order: null - remote_table: - name: proposal_staking_pool_snapshot - schema: public + - name: proposal_tally_result + using: + manual_configuration: + column_mapping: + id: proposal_id + insertion_order: null + remote_table: + name: proposal_tally_result + schema: public + - name: proposer + using: + foreign_key_constraint_on: proposer_address + - name: staking_pool_snapshot + using: + manual_configuration: + column_mapping: + id: proposal_id + insertion_order: null + remote_table: + name: proposal_staking_pool_snapshot + schema: public array_relationships: -- name: proposal_deposits - using: - foreign_key_constraint_on: - column: proposal_id - table: - name: proposal_deposit + - name: proposal_deposits + using: + foreign_key_constraint_on: + column: proposal_id + table: + name: proposal_deposit + schema: public + - name: proposal_tally_results + using: + foreign_key_constraint_on: + column: proposal_id + table: + name: proposal_tally_result + schema: public + - name: proposal_votes + using: + foreign_key_constraint_on: + column: proposal_id + table: + name: proposal_vote + schema: public + - name: validator_status_snapshots + using: + foreign_key_constraint_on: + column: proposal_id + table: + name: proposal_validator_status_snapshot + schema: public +computed_fields: + - name: active_first_order + definition: + function: + name: active_first schema: public -- name: proposal_tally_results - using: - foreign_key_constraint_on: - column: proposal_id - table: - name: proposal_tally_result + - name: failed_first_order + definition: + function: + name: failed_first schema: public -- name: proposal_votes - using: - foreign_key_constraint_on: - column: proposal_id - table: - name: proposal_vote + - name: passed_first_order + definition: + function: + name: passed_first schema: public -- name: validator_status_snapshots - using: - foreign_key_constraint_on: - column: proposal_id - table: - name: proposal_validator_status_snapshot + - name: rejected_first_order + definition: + function: + name: rejected_first schema: public select_permissions: -- permission: - allow_aggregations: true - columns: - - title - - description - - proposal_route - - proposal_type - - id - - submit_time - - deposit_end_time - - voting_start_time - - voting_end_time - - proposer_address - - status - - content - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - title + - description + - proposal_route + - proposal_type + - id + - submit_time + - deposit_end_time + - voting_start_time + - voting_end_time + - proposer_address + - status + - content + computed_fields: + - active_first_order + - failed_first_order + - passed_first_order + - rejected_first_order + filter: {} + limit: 100 + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml index 01e208c16..05ca9b77a 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml @@ -2,30 +2,29 @@ table: name: proposal_deposit schema: public object_relationships: -- name: block - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: block - schema: public -- name: depositor - using: - foreign_key_constraint_on: depositor_address -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: block + using: + manual_configuration: + column_mapping: + height: height + insertion_order: null + remote_table: + name: block + schema: public + - name: depositor + using: + foreign_key_constraint_on: depositor_address + - name: proposal + using: + foreign_key_constraint_on: proposal_id select_permissions: -- permission: - allow_aggregations: false - columns: - - proposal_id - - depositor_address - - amount - - timestamp - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - depositor_address + - amount + - timestamp + - height + filter: {} + limit: 100 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 6c9fe014f..ac27c7fd6 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 @@ -2,17 +2,16 @@ table: name: proposal_staking_pool_snapshot schema: public object_relationships: -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: proposal + using: + foreign_key_constraint_on: proposal_id select_permissions: -- permission: - allow_aggregations: false - columns: - - proposal_id - - bonded_tokens - - not_bonded_tokens - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - bonded_tokens + - not_bonded_tokens + - height + filter: {} + limit: 100 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 451d91e07..a5b1a7203 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml @@ -2,19 +2,18 @@ table: name: proposal_tally_result schema: public object_relationships: -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: proposal + using: + foreign_key_constraint_on: proposal_id select_permissions: -- permission: - allow_aggregations: false - columns: - - proposal_id - - yes - - abstain - - no - - no_with_veto - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - "yes" + - abstain + - "no" + - no_with_veto + - height + filter: {} + limit: 100 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 6869f9a36..564a1c06b 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 @@ -2,22 +2,21 @@ table: name: proposal_validator_status_snapshot schema: public object_relationships: -- name: proposal - using: - foreign_key_constraint_on: proposal_id -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: proposal + using: + foreign_key_constraint_on: proposal_id + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: false - columns: - - proposal_id - - validator_address - - voting_power - - status - - jailed - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - validator_address + - voting_power + - status + - jailed + - height + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml index 60f3694be..e683c3c79 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml @@ -2,30 +2,32 @@ table: name: proposal_vote schema: public object_relationships: -- name: account - using: - foreign_key_constraint_on: voter_address -- name: block - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: block - schema: public -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: account + using: + foreign_key_constraint_on: voter_address + - name: block + using: + 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: false - columns: - - proposal_id - - voter_address - - option - - timestamp - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - voter_address + - option + - weight + - is_valid + - timestamp + - height + filter: {} + limit: 100 + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml index 912e8fc66..e40a248f9 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml @@ -2,11 +2,10 @@ table: name: slashing_params schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - params - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - params + - height + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_software_upgrade_plan.yaml b/hasura/metadata/databases/bdjuno/tables/public_software_upgrade_plan.yaml index d7ab38f50..523071ad6 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_software_upgrade_plan.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_software_upgrade_plan.yaml @@ -2,17 +2,17 @@ table: name: software_upgrade_plan schema: public object_relationships: -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: proposal + using: + foreign_key_constraint_on: proposal_id select_permissions: -- permission: - allow_aggregations: true - columns: - - proposal_id - - plan_name - - upgrade_height - - info - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - plan_name + - upgrade_height + - info + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml index 2cb4e10c7..ff7019a29 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml @@ -2,11 +2,10 @@ table: name: staking_params schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - params - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - params + - height + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml b/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml index 2c4ef61e5..fa95461f6 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml @@ -2,14 +2,13 @@ table: name: staking_pool schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - height - - bonded_tokens - - not_bonded_tokens - - unbonding_tokens - - staked_not_bonded_tokens - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - height + - bonded_tokens + - not_bonded_tokens + - unbonding_tokens + - staked_not_bonded_tokens + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_supply.yaml b/hasura/metadata/databases/bdjuno/tables/public_supply.yaml index 8f278c980..28b36251b 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_supply.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_supply.yaml @@ -2,11 +2,10 @@ table: name: supply schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - coins - - height - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - coins + - height + filter: {} + limit: 1 diff --git a/hasura/metadata/databases/bdjuno/tables/public_token.yaml b/hasura/metadata/databases/bdjuno/tables/public_token.yaml index e1b4a746a..632d182cc 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token.yaml @@ -2,18 +2,17 @@ table: name: token schema: public array_relationships: -- name: token_units - using: - foreign_key_constraint_on: - column: token_name - table: - name: token_unit - schema: public + - name: token_units + using: + foreign_key_constraint_on: + column: token_name + table: + name: token_unit + schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - name - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - name + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml b/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml index 7c2a1fa0b..d2692e516 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml @@ -2,17 +2,16 @@ table: name: token_price schema: public object_relationships: -- name: token_unit - using: - foreign_key_constraint_on: unit_name + - name: token_unit + using: + foreign_key_constraint_on: unit_name select_permissions: -- permission: - allow_aggregations: false - columns: - - unit_name - - price - - market_cap - - timestamp - filter: {} - limit: 1 - role: anonymous + - role: anonymous + permission: + columns: + - unit_name + - price + - market_cap + - timestamp + filter: {} + limit: 1 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 809f0a170..848d4bc9e 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml @@ -2,17 +2,16 @@ table: name: token_price_history schema: public object_relationships: -- name: token_unit - using: - foreign_key_constraint_on: unit_name + - name: token_unit + using: + foreign_key_constraint_on: unit_name select_permissions: -- permission: - allow_aggregations: false - columns: - - market_cap - - price - - timestamp - - unit_name - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - market_cap + - price + - timestamp + - unit_name + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml b/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml index cd30c03f4..8357b2b7c 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml @@ -2,42 +2,41 @@ table: name: token_unit schema: public object_relationships: -- name: token - using: - foreign_key_constraint_on: token_name -- name: token_price - using: - manual_configuration: - column_mapping: - denom: unit_name - insertion_order: null - remote_table: - name: token_price - schema: public + - name: token + using: + foreign_key_constraint_on: token_name + - name: token_price + using: + manual_configuration: + column_mapping: + denom: unit_name + insertion_order: null + remote_table: + name: token_price + schema: public array_relationships: -- name: token_price_histories - using: - foreign_key_constraint_on: - column: unit_name - table: - name: token_price_history - schema: public -- name: token_prices - using: - foreign_key_constraint_on: - column: unit_name - table: - name: token_price - schema: public + - name: token_price_histories + using: + foreign_key_constraint_on: + column: unit_name + table: + name: token_price_history + schema: public + - name: token_prices + using: + foreign_key_constraint_on: + column: unit_name + table: + name: token_price + schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - aliases - - denom - - exponent - - price_id - - token_name - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - aliases + - denom + - exponent + - price_id + - token_name + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml b/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml index df1e20fe1..29f5e1b53 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml @@ -2,25 +2,24 @@ table: name: transaction schema: public object_relationships: -- name: block - using: - foreign_key_constraint_on: height + - name: block + using: + foreign_key_constraint_on: height select_permissions: -- permission: - allow_aggregations: false - columns: - - hash - - height - - success - - messages - - memo - - signatures - - signer_infos - - fee - - gas_wanted - - gas_used - - raw_log - - logs - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - hash + - height + - success + - messages + - memo + - signatures + - signer_infos + - fee + - gas_wanted + - gas_used + - raw_log + - logs + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator.yaml index b4eac1c63..26f21a74e 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator.yaml @@ -2,103 +2,102 @@ table: name: validator schema: public object_relationships: -- name: validator_info - using: - manual_configuration: - column_mapping: - consensus_address: consensus_address - insertion_order: null - remote_table: - name: validator_info - schema: public -- name: proposal_validator_status_snapshot - using: - manual_configuration: - column_mapping: - consensus_address: validator_address - insertion_order: null - remote_table: - name: proposal_validator_status_snapshot - schema: public + - name: proposal_validator_status_snapshot + using: + manual_configuration: + column_mapping: + consensus_address: validator_address + insertion_order: null + remote_table: + name: proposal_validator_status_snapshot + schema: public + - name: validator_info + using: + manual_configuration: + column_mapping: + consensus_address: consensus_address + insertion_order: null + remote_table: + name: validator_info + schema: public array_relationships: -- name: blocks - using: - foreign_key_constraint_on: - column: proposer_address - table: - name: block - schema: public -- name: double_sign_votes - using: - foreign_key_constraint_on: - column: validator_address - table: - name: double_sign_vote - schema: public -- name: pre_commits - using: - foreign_key_constraint_on: - column: validator_address - table: - name: pre_commit - schema: public -- name: validator_commissions - using: - foreign_key_constraint_on: - column: validator_address - table: - name: validator_commission - schema: public -- name: validator_descriptions - using: - foreign_key_constraint_on: - column: validator_address - table: - name: validator_description - schema: public -- name: validator_infos - using: - foreign_key_constraint_on: - column: consensus_address - table: - name: validator_info - schema: public -- name: validator_signing_infos - using: - manual_configuration: - column_mapping: - consensus_address: validator_address - insertion_order: null - remote_table: - name: validator_signing_info - schema: public -- name: validator_statuses - using: - foreign_key_constraint_on: - column: validator_address - table: - name: validator_status - schema: public -- name: validator_voting_powers - using: - foreign_key_constraint_on: - column: validator_address - table: - name: validator_voting_power - schema: public -- name: proposal_validator_status_snapshots - using: - foreign_key_constraint_on: - column: validator_address - table: - name: proposal_validator_status_snapshot - schema: public + - name: blocks + using: + foreign_key_constraint_on: + column: proposer_address + table: + name: block + schema: public + - name: double_sign_votes + using: + foreign_key_constraint_on: + column: validator_address + table: + name: double_sign_vote + schema: public + - name: pre_commits + using: + foreign_key_constraint_on: + column: validator_address + table: + name: pre_commit + schema: public + - name: proposal_validator_status_snapshots + using: + foreign_key_constraint_on: + column: validator_address + table: + name: proposal_validator_status_snapshot + schema: public + - name: validator_commissions + using: + foreign_key_constraint_on: + column: validator_address + table: + name: validator_commission + schema: public + - name: validator_descriptions + using: + foreign_key_constraint_on: + column: validator_address + table: + name: validator_description + schema: public + - name: validator_infos + using: + foreign_key_constraint_on: + column: consensus_address + table: + name: validator_info + schema: public + - name: validator_signing_infos + using: + manual_configuration: + column_mapping: + consensus_address: validator_address + insertion_order: null + remote_table: + name: validator_signing_info + schema: public + - name: validator_statuses + using: + foreign_key_constraint_on: + column: validator_address + table: + name: validator_status + schema: public + - name: validator_voting_powers + using: + foreign_key_constraint_on: + column: validator_address + table: + name: validator_voting_power + schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - consensus_address - - consensus_pubkey - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - consensus_address + - consensus_pubkey + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml index 17a916133..4927930d0 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml @@ -2,17 +2,16 @@ table: name: validator_commission schema: public object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: false - columns: - - validator_address - - commission - - min_self_delegation - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - commission + - min_self_delegation + - height + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml index ca95d9400..445f6ba83 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml @@ -2,21 +2,20 @@ table: name: validator_description schema: public object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: false - columns: - - validator_address - - moniker - - identity - - website - - security_contact - - details - - height - - avatar_url - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - moniker + - identity + - website + - security_contact + - details + - height + - avatar_url + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml index 0979040eb..39f4b213f 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml @@ -2,21 +2,20 @@ table: name: validator_info schema: public object_relationships: -- name: account - using: - foreign_key_constraint_on: self_delegate_address -- name: validator - using: - foreign_key_constraint_on: consensus_address + - name: account + using: + foreign_key_constraint_on: self_delegate_address + - name: validator + using: + foreign_key_constraint_on: consensus_address select_permissions: -- permission: - allow_aggregations: false - columns: - - consensus_address - - operator_address - - self_delegate_address - - max_change_rate - - max_rate - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - consensus_address + - operator_address + - self_delegate_address + - max_change_rate + - max_rate + filter: {} + limit: 100 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 8040e8a26..a6ceed97e 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml @@ -2,16 +2,15 @@ table: name: validator_signing_info schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - validator_address - - start_height - - index_offset - - jailed_until - - tombstoned - - missed_blocks_counter - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - start_height + - index_offset + - jailed_until + - tombstoned + - missed_blocks_counter + - height + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml index 32f212d54..1d6f8e538 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml @@ -2,17 +2,17 @@ table: name: validator_status schema: public object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - status - - jailed - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - status + - jailed + - height + filter: {} + limit: 100 + allow_aggregations: true 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 fc5f76302..6b4972ead 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml @@ -2,19 +2,19 @@ table: name: validator_voting_power schema: public object_relationships: -- name: block - using: - foreign_key_constraint_on: height -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: block + using: + foreign_key_constraint_on: height + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - voting_power - - height - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - voting_power + - height + filter: {} + limit: 100 + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml b/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml index aba91ce74..37b503c53 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml @@ -2,26 +2,25 @@ table: name: vesting_account schema: public object_relationships: -- name: account - using: - foreign_key_constraint_on: address + - name: account + using: + foreign_key_constraint_on: address array_relationships: -- name: vesting_periods - using: - foreign_key_constraint_on: - column: vesting_account_id - table: - name: vesting_period - schema: public + - name: vesting_periods + using: + foreign_key_constraint_on: + column: vesting_account_id + table: + name: vesting_period + schema: public select_permissions: -- permission: - allow_aggregations: false - columns: - - type - - address - - original_vesting - - end_time - - start_time - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - type + - address + - original_vesting + - end_time + - start_time + filter: {} + limit: 100 diff --git a/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml b/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml index f56da44ac..fd0e5c464 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml @@ -2,16 +2,15 @@ table: name: vesting_period schema: public object_relationships: -- name: vesting_account - using: - foreign_key_constraint_on: vesting_account_id + - name: vesting_account + using: + foreign_key_constraint_on: vesting_account_id select_permissions: -- permission: - allow_aggregations: false - columns: - - period_order - - length - - amount - filter: {} - limit: 100 - role: anonymous + - role: anonymous + permission: + columns: + - period_order + - length + - amount + filter: {} + limit: 100 diff --git a/hasura/metadata/graphql_schema_introspection.yaml b/hasura/metadata/graphql_schema_introspection.yaml new file mode 100644 index 000000000..61a4dcac2 --- /dev/null +++ b/hasura/metadata/graphql_schema_introspection.yaml @@ -0,0 +1 @@ +disabled_for_roles: [] diff --git a/hasura/metadata/inherited_roles.yaml b/hasura/metadata/inherited_roles.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/metadata/inherited_roles.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/metrics_config.yaml b/hasura/metadata/metrics_config.yaml new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/hasura/metadata/metrics_config.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/network.yaml b/hasura/metadata/network.yaml new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/hasura/metadata/network.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/opentelemetry.yaml b/hasura/metadata/opentelemetry.yaml new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/hasura/metadata/opentelemetry.yaml @@ -0,0 +1 @@ +{} diff --git a/modules/gov/handle_msg.go b/modules/gov/handle_msg.go index e9a4f6084..24d82c9ba 100644 --- a/modules/gov/handle_msg.go +++ b/modules/gov/handle_msg.go @@ -32,6 +32,8 @@ func (m *Module) HandleMsg(index int, msg sdk.Msg, tx *juno.Tx) error { return m.handleMsgDeposit(tx, cosmosMsg) case *govtypes.MsgVote: return m.handleMsgVote(tx, cosmosMsg) + case *govtypes.MsgVoteWeighted: + return m.handleMsgVoteWeighted(tx, cosmosMsg) } return nil @@ -113,7 +115,31 @@ func (m *Module) handleMsgVote(tx *juno.Tx, msg *govtypes.MsgVote) error { return fmt.Errorf("error while parsing time: %s", err) } - vote := types.NewVote(msg.ProposalId, msg.Voter, msg.Option, txTimestamp, tx.Height) - + vote := types.NewVote(msg.ProposalId, msg.Voter, msg.Option, "1.0", txTimestamp, tx.Height) + err = m.db.CleanVote(msg.ProposalId, msg.Voter) + if err != nil { + return err + } return m.db.SaveVote(vote) } + +func (m *Module) handleMsgVoteWeighted(tx *juno.Tx, msg *govtypes.MsgVoteWeighted) error { + txTimestamp, err := time.Parse(time.RFC3339, tx.Timestamp) + if err != nil { + return fmt.Errorf("error while parsing time: %s", err) + } + err = m.db.CleanVote(msg.ProposalId, msg.Voter) + if err != nil { + return err + } + for _, option := range msg.Options { + vote := types.NewVote(msg.ProposalId, msg.Voter, option.Option, option.Weight.String(), txTimestamp, tx.Height) + err = m.db.SaveVote(vote) + if err != nil { + return fmt.Errorf("error while saving weighted vote for address %s: %s", msg.Voter, err) + } + } + + // update tally result for given proposal + return m.updateProposalTallyResult(msg.ProposalId, tx.Height) +} diff --git a/modules/gov/utils_proposal.go b/modules/gov/utils_proposal.go index 956702525..7f601f05d 100644 --- a/modules/gov/utils_proposal.go +++ b/modules/gov/utils_proposal.go @@ -41,10 +41,11 @@ func (m *Module) UpdateProposal(height int64, blockTime time.Time, id uint64) er if err != nil { return fmt.Errorf("error while updating proposal status: %s", err) } - - err = m.updateProposalTallyResult(proposal) - if err != nil { - return fmt.Errorf("error while updating proposal tally result: %s", err) + if proposal.Status == govtypes.StatusVotingPeriod { + err = m.updateProposalTallyResult(proposal.ProposalId, height) + if err != nil { + return fmt.Errorf("error while updating proposal tally result: %s", err) + } } err = m.updateAccounts(proposal) @@ -150,20 +151,15 @@ func (m *Module) updateProposalStatus(proposal govtypes.Proposal) error { } // updateProposalTallyResult updates the tally result associated with the given proposal -func (m *Module) updateProposalTallyResult(proposal govtypes.Proposal) error { - height, err := m.db.GetLastBlockHeight() - if err != nil { - return err - } - - result, err := m.source.TallyResult(height, proposal.ProposalId) +func (m *Module) updateProposalTallyResult(proposalId uint64, height int64) error { + result, err := m.source.TallyResult(height, proposalId) if err != nil { return fmt.Errorf("error while getting tally result: %s", err) } return m.db.SaveTallyResults([]types.TallyResult{ types.NewTallyResult( - proposal.ProposalId, + proposalId, result.Yes.String(), result.Abstain.String(), result.No.String(), diff --git a/types/gov.go b/types/gov.go index bc6b6856d..79d73ca44 100644 --- a/types/gov.go +++ b/types/gov.go @@ -194,6 +194,7 @@ type Vote struct { ProposalID uint64 Voter string Option govtypes.VoteOption + Weight string Timestamp time.Time Height int64 } @@ -203,6 +204,7 @@ func NewVote( proposalID uint64, voter string, option govtypes.VoteOption, + weight string, timestamp time.Time, height int64, ) Vote { @@ -210,6 +212,7 @@ func NewVote( ProposalID: proposalID, Voter: voter, Option: option, + Weight: weight, Timestamp: timestamp, Height: height, }