From 3d26b7bcef1f25e8258e7fb80ee5afade5185b59 Mon Sep 17 00:00:00 2001 From: albttx Date: Wed, 11 Sep 2024 19:39:18 +0100 Subject: [PATCH] chore: add anonymous role --- docker-compose.yml | 3 +++ .../default/tables/public_accounts.yaml | 8 +++++++ .../public_average_block_time_per_days.yaml | 9 +++++++ .../public_average_block_time_per_hours.yaml | 9 +++++++ ...public_average_block_time_per_minutes.yaml | 9 +++++++ .../default/tables/public_balances.yaml | 9 +++++++ .../default/tables/public_blocks.yaml | 12 ++++++++++ .../default/tables/public_gov_params.yaml | 10 ++++++++ .../tables/public_proposal_deposits.yaml | 11 +++++++++ ...ublic_proposal_staking_pool_snapshots.yaml | 10 ++++++++ .../tables/public_proposal_tally_results.yaml | 12 ++++++++++ ...c_proposal_validator_status_snapshots.yaml | 13 ++++++++++ .../default/tables/public_proposal_votes.yaml | 14 +++++++++++ .../default/tables/public_proposals.yaml | 24 +++++++++++++++++++ .../tables/public_staked_balances.yaml | 10 ++++++++ .../default/tables/public_staking_params.yaml | 8 +++++++ .../default/tables/public_staking_pools.yaml | 9 +++++++ .../default/tables/public_supplies.yaml | 8 +++++++ .../default/tables/public_transactions.yaml | 18 ++++++++++++++ .../tables/public_validator_commissions.yaml | 10 ++++++++ .../tables/public_validator_descriptions.yaml | 14 +++++++++++ .../tables/public_validator_infos.yaml | 12 ++++++++++ .../tables/public_validator_statuses.yaml | 10 ++++++++ .../public_validator_voting_powers.yaml | 9 +++++++ .../default/tables/public_validators.yaml | 8 +++++++ src/apolloClient.ts | 4 ++++ 26 files changed, 273 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 24c7d60..e3918b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,10 @@ services: networks: - eclesia-indexer_default environment: + # whitelist of gql queries for security purpose HASURA_GRAPHQL_ENABLE_ALLOWLIST: "true" + # queries are send with x-hasura-role: anonymous + HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "anonymous" ## postgres database to store Hasura metadata HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/metadata-govgen-dapp ## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs diff --git a/hasura/metadata/databases/default/tables/public_accounts.yaml b/hasura/metadata/databases/default/tables/public_accounts.yaml index 68e6d56..049b324 100644 --- a/hasura/metadata/databases/default/tables/public_accounts.yaml +++ b/hasura/metadata/databases/default/tables/public_accounts.yaml @@ -52,3 +52,11 @@ array_relationships: table: name: validator_infos schema: public +select_permissions: +- comment: "" + permission: + allow_aggregations: true + columns: + - address + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_average_block_time_per_days.yaml b/hasura/metadata/databases/default/tables/public_average_block_time_per_days.yaml index f68fcb3..0428519 100644 --- a/hasura/metadata/databases/default/tables/public_average_block_time_per_days.yaml +++ b/hasura/metadata/databases/default/tables/public_average_block_time_per_days.yaml @@ -9,3 +9,12 @@ configuration: insert_one: insert_average_block_time_per_day select_by_pk: average_block_time_per_day update_by_pk: update_average_block_time_per_day +select_permissions: +- comment: "" + permission: + columns: + - height + - one_row_id + - average_time + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_average_block_time_per_hours.yaml b/hasura/metadata/databases/default/tables/public_average_block_time_per_hours.yaml index ffab5b4..20379b6 100644 --- a/hasura/metadata/databases/default/tables/public_average_block_time_per_hours.yaml +++ b/hasura/metadata/databases/default/tables/public_average_block_time_per_hours.yaml @@ -9,3 +9,12 @@ configuration: insert_one: insert_average_block_time_per_hour select_by_pk: average_block_time_per_hour update_by_pk: update_average_block_time_per_hour +select_permissions: +- comment: "" + permission: + columns: + - height + - one_row_id + - average_time + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_average_block_time_per_minutes.yaml b/hasura/metadata/databases/default/tables/public_average_block_time_per_minutes.yaml index 723ae49..72f3db1 100644 --- a/hasura/metadata/databases/default/tables/public_average_block_time_per_minutes.yaml +++ b/hasura/metadata/databases/default/tables/public_average_block_time_per_minutes.yaml @@ -9,3 +9,12 @@ configuration: insert_one: insert_average_block_time_per_minute select_by_pk: average_block_time_per_minute update_by_pk: update_average_block_time_per_minute +select_permissions: +- comment: "" + permission: + columns: + - height + - one_row_id + - average_time + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_balances.yaml b/hasura/metadata/databases/default/tables/public_balances.yaml index 8c61ffc..04eef8e 100644 --- a/hasura/metadata/databases/default/tables/public_balances.yaml +++ b/hasura/metadata/databases/default/tables/public_balances.yaml @@ -16,3 +16,12 @@ object_relationships: - name: block using: foreign_key_constraint_on: height +select_permissions: +- comment: "" + permission: + columns: + - coins + - height + - address + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_blocks.yaml b/hasura/metadata/databases/default/tables/public_blocks.yaml index a45fc37..43c3e4c 100644 --- a/hasura/metadata/databases/default/tables/public_blocks.yaml +++ b/hasura/metadata/databases/default/tables/public_blocks.yaml @@ -105,3 +105,15 @@ array_relationships: table: name: validator_voting_powers schema: public +select_permissions: +- comment: "" + permission: + columns: + - height + - total_gas + - num_txs + - hash + - proposer_address + - timestamp + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_gov_params.yaml b/hasura/metadata/databases/default/tables/public_gov_params.yaml index b0dbba8..b61177a 100644 --- a/hasura/metadata/databases/default/tables/public_gov_params.yaml +++ b/hasura/metadata/databases/default/tables/public_gov_params.yaml @@ -13,3 +13,13 @@ object_relationships: - name: block using: foreign_key_constraint_on: height +select_permissions: +- comment: "" + permission: + columns: + - height + - deposit_params + - tally_params + - voting_params + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_proposal_deposits.yaml b/hasura/metadata/databases/default/tables/public_proposal_deposits.yaml index b4101fb..d8e1a53 100644 --- a/hasura/metadata/databases/default/tables/public_proposal_deposits.yaml +++ b/hasura/metadata/databases/default/tables/public_proposal_deposits.yaml @@ -19,3 +19,14 @@ object_relationships: - name: proposal using: foreign_key_constraint_on: proposal_id +select_permissions: +- comment: "" + permission: + columns: + - amount + - height + - proposal_id + - depositor_address + - timestamp + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_proposal_staking_pool_snapshots.yaml b/hasura/metadata/databases/default/tables/public_proposal_staking_pool_snapshots.yaml index 722daf9..73f18c9 100644 --- a/hasura/metadata/databases/default/tables/public_proposal_staking_pool_snapshots.yaml +++ b/hasura/metadata/databases/default/tables/public_proposal_staking_pool_snapshots.yaml @@ -13,3 +13,13 @@ object_relationships: - name: proposal using: foreign_key_constraint_on: proposal_id +select_permissions: +- comment: "" + permission: + columns: + - height + - proposal_id + - bonded_tokens + - not_bonded_tokens + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_proposal_tally_results.yaml b/hasura/metadata/databases/default/tables/public_proposal_tally_results.yaml index 940e478..420963d 100644 --- a/hasura/metadata/databases/default/tables/public_proposal_tally_results.yaml +++ b/hasura/metadata/databases/default/tables/public_proposal_tally_results.yaml @@ -16,3 +16,15 @@ object_relationships: - name: proposal using: foreign_key_constraint_on: proposal_id +select_permissions: +- comment: "" + permission: + columns: + - height + - proposal_id + - abstain + - no + - no_with_veto + - yes + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_proposal_validator_status_snapshots.yaml b/hasura/metadata/databases/default/tables/public_proposal_validator_status_snapshots.yaml index eb2384b..b6449bd 100644 --- a/hasura/metadata/databases/default/tables/public_proposal_validator_status_snapshots.yaml +++ b/hasura/metadata/databases/default/tables/public_proposal_validator_status_snapshots.yaml @@ -16,3 +16,16 @@ object_relationships: - name: validator using: foreign_key_constraint_on: validator_address +select_permissions: +- comment: "" + permission: + columns: + - height + - voting_power + - jailed + - id + - proposal_id + - status + - validator_address + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_proposal_votes.yaml b/hasura/metadata/databases/default/tables/public_proposal_votes.yaml index e17c54d..ee0c749 100644 --- a/hasura/metadata/databases/default/tables/public_proposal_votes.yaml +++ b/hasura/metadata/databases/default/tables/public_proposal_votes.yaml @@ -19,3 +19,17 @@ object_relationships: - name: proposal using: foreign_key_constraint_on: proposal_id +select_permissions: +- comment: "" + permission: + allow_aggregations: true + columns: + - height + - is_valid + - proposal_id + - option + - voter_address + - weight + - timestamp + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_proposals.yaml b/hasura/metadata/databases/default/tables/public_proposals.yaml index 8142e74..e812163 100644 --- a/hasura/metadata/databases/default/tables/public_proposals.yaml +++ b/hasura/metadata/databases/default/tables/public_proposals.yaml @@ -70,3 +70,27 @@ computed_fields: name: rejected_first schema: public name: rejected_first_order +select_permissions: +- comment: "" + permission: + allow_aggregations: true + columns: + - id + - content + - description + - proposal_route + - proposal_type + - proposer_address + - status + - title + - deposit_end_time + - submit_time + - voting_end_time + - voting_start_time + computed_fields: + - active_first_order + - failed_first_order + - passed_first_order + - rejected_first_order + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_staked_balances.yaml b/hasura/metadata/databases/default/tables/public_staked_balances.yaml index 343d068..3f2e37c 100644 --- a/hasura/metadata/databases/default/tables/public_staked_balances.yaml +++ b/hasura/metadata/databases/default/tables/public_staked_balances.yaml @@ -19,3 +19,13 @@ object_relationships: - name: validatorByValidator using: foreign_key_constraint_on: validator +select_permissions: +- comment: "" + permission: + columns: + - amount + - height + - delegator + - validator + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_staking_params.yaml b/hasura/metadata/databases/default/tables/public_staking_params.yaml index 44a71bd..af22330 100644 --- a/hasura/metadata/databases/default/tables/public_staking_params.yaml +++ b/hasura/metadata/databases/default/tables/public_staking_params.yaml @@ -9,3 +9,11 @@ configuration: insert_one: insert_staking_param select_by_pk: staking_param update_by_pk: update_staking_param +select_permissions: +- comment: "" + permission: + columns: + - height + - params + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_staking_pools.yaml b/hasura/metadata/databases/default/tables/public_staking_pools.yaml index 5fc72e2..9d3839d 100644 --- a/hasura/metadata/databases/default/tables/public_staking_pools.yaml +++ b/hasura/metadata/databases/default/tables/public_staking_pools.yaml @@ -9,3 +9,12 @@ configuration: insert_one: insert_staking_pool select_by_pk: staking_pool update_by_pk: update_staking_pool +select_permissions: +- comment: "" + permission: + columns: + - height + - bonded_tokens + - not_bonded_tokens + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_supplies.yaml b/hasura/metadata/databases/default/tables/public_supplies.yaml index b14971a..24bb5ab 100644 --- a/hasura/metadata/databases/default/tables/public_supplies.yaml +++ b/hasura/metadata/databases/default/tables/public_supplies.yaml @@ -13,3 +13,11 @@ object_relationships: - name: block using: foreign_key_constraint_on: height +select_permissions: +- comment: "" + permission: + columns: + - coins + - height + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_transactions.yaml b/hasura/metadata/databases/default/tables/public_transactions.yaml index 69bf11d..d6f3f67 100644 --- a/hasura/metadata/databases/default/tables/public_transactions.yaml +++ b/hasura/metadata/databases/default/tables/public_transactions.yaml @@ -13,3 +13,21 @@ object_relationships: - name: block using: foreign_key_constraint_on: height +select_permissions: +- comment: "" + permission: + columns: + - signatures + - gas_used + - gas_wanted + - height + - success + - fee + - logs + - messages + - signer_infos + - hash + - memo + - raw_log + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_validator_commissions.yaml b/hasura/metadata/databases/default/tables/public_validator_commissions.yaml index 4b3982c..0aa0c93 100644 --- a/hasura/metadata/databases/default/tables/public_validator_commissions.yaml +++ b/hasura/metadata/databases/default/tables/public_validator_commissions.yaml @@ -16,3 +16,13 @@ object_relationships: - name: validator_info using: foreign_key_constraint_on: validator_address +select_permissions: +- comment: "" + permission: + columns: + - height + - min_self_delegation + - commission + - validator_address + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_validator_descriptions.yaml b/hasura/metadata/databases/default/tables/public_validator_descriptions.yaml index 09f08f2..2e700f8 100644 --- a/hasura/metadata/databases/default/tables/public_validator_descriptions.yaml +++ b/hasura/metadata/databases/default/tables/public_validator_descriptions.yaml @@ -16,3 +16,17 @@ object_relationships: - name: validator_info using: foreign_key_constraint_on: validator_address +select_permissions: +- comment: "" + permission: + columns: + - height + - avatar_url + - details + - identity + - moniker + - security_contact + - validator_address + - website + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_validator_infos.yaml b/hasura/metadata/databases/default/tables/public_validator_infos.yaml index b59a725..5f753d6 100644 --- a/hasura/metadata/databases/default/tables/public_validator_infos.yaml +++ b/hasura/metadata/databases/default/tables/public_validator_infos.yaml @@ -48,3 +48,15 @@ array_relationships: table: name: validator_voting_powers schema: public +select_permissions: +- comment: "" + permission: + columns: + - height + - consensus_address + - max_change_rate + - max_rate + - operator_address + - self_delegate_address + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_validator_statuses.yaml b/hasura/metadata/databases/default/tables/public_validator_statuses.yaml index 40facf0..c5dc8bf 100644 --- a/hasura/metadata/databases/default/tables/public_validator_statuses.yaml +++ b/hasura/metadata/databases/default/tables/public_validator_statuses.yaml @@ -16,3 +16,13 @@ object_relationships: - name: validator_info using: foreign_key_constraint_on: validator_address +select_permissions: +- comment: "" + permission: + columns: + - height + - jailed + - status + - validator_address + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_validator_voting_powers.yaml b/hasura/metadata/databases/default/tables/public_validator_voting_powers.yaml index c1c6b69..5fa2aa3 100644 --- a/hasura/metadata/databases/default/tables/public_validator_voting_powers.yaml +++ b/hasura/metadata/databases/default/tables/public_validator_voting_powers.yaml @@ -16,3 +16,12 @@ object_relationships: - name: validator_info using: foreign_key_constraint_on: validator_address +select_permissions: +- comment: "" + permission: + columns: + - height + - voting_power + - validator_address + filter: {} + role: anonymous diff --git a/hasura/metadata/databases/default/tables/public_validators.yaml b/hasura/metadata/databases/default/tables/public_validators.yaml index cd4dc61..e311518 100644 --- a/hasura/metadata/databases/default/tables/public_validators.yaml +++ b/hasura/metadata/databases/default/tables/public_validators.yaml @@ -39,3 +39,11 @@ array_relationships: table: name: staked_balances schema: public +select_permissions: +- comment: "" + permission: + columns: + - consensus_address + - consensus_pubkey + filter: {} + role: anonymous diff --git a/src/apolloClient.ts b/src/apolloClient.ts index 95551c1..64c8e2b 100644 --- a/src/apolloClient.ts +++ b/src/apolloClient.ts @@ -6,6 +6,10 @@ console.log("[DEBUG] env", import.meta.env); const httpLink = createHttpLink({ // You should use an absolute URL here uri: import.meta.env.VITE_GRAPHQL_ENDPOINT ?? "https://graphql-devnet.govgen.dev/v1/graphql", + + headers: { + "x-hasura-role": "anonymous", + }, }); // Cache implementation