From 6f1ddd9b482b746eaf2940c41f9150e84244727c Mon Sep 17 00:00:00 2001 From: Rhys Bartels-Waller Date: Fri, 17 Sep 2021 13:33:18 +1000 Subject: [PATCH] feature: include all reward types in Reward model, adds `type` field BREAKING CHANGE: `Reward.stakePool` is now nullable to handle rewards of type `treasury` or `reserves`. --- .../hasura/project/migrations/1589369664961_init/up.sql | 6 +++--- packages/api-cardano-db-hasura/schema.graphql | 5 ++++- .../src/example_queries/rewards/rewardsForAddress.graphql | 1 + packages/api-cardano-db-hasura/test/rewards.query.test.ts | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/api-cardano-db-hasura/hasura/project/migrations/1589369664961_init/up.sql b/packages/api-cardano-db-hasura/hasura/project/migrations/1589369664961_init/up.sql index 1071be70..7dbce908 100644 --- a/packages/api-cardano-db-hasura/hasura/project/migrations/1589369664961_init/up.sql +++ b/packages/api-cardano-db-hasura/hasura/project/migrations/1589369664961_init/up.sql @@ -149,10 +149,10 @@ SELECT reward.amount, stake_address.view AS "address", reward.earned_epoch AS "earnedInEpochNo", - reward.pool_id AS pool_hash_id + reward.pool_id AS pool_hash_id, + reward.type AS "type" FROM reward -JOIN stake_address on reward.addr_id = stake_address.id -WHERE type = 'member'; +JOIN stake_address on reward.addr_id = stake_address.id; CREATE VIEW "Script" AS SELECT diff --git a/packages/api-cardano-db-hasura/schema.graphql b/packages/api-cardano-db-hasura/schema.graphql index 5a17b88c..d6ed3c2e 100644 --- a/packages/api-cardano-db-hasura/schema.graphql +++ b/packages/api-cardano-db-hasura/schema.graphql @@ -609,7 +609,8 @@ type Reward { address: StakeAddress! amount: String! earnedIn: Epoch! - stakePool: StakePool! + stakePool: StakePool + type: String! } type Reward_aggregate { @@ -648,6 +649,7 @@ input Reward_bool_exp { amount: text_comparison_exp earnedIn: Epoch_bool_exp stakePool: StakePool_bool_exp + type: text_comparison_exp } input Reward_order_by { @@ -655,6 +657,7 @@ input Reward_order_by { amount: order_by earnedIn: Epoch_order_by stakePool: StakePool_order_by + type: order_by } type Script { diff --git a/packages/api-cardano-db-hasura/src/example_queries/rewards/rewardsForAddress.graphql b/packages/api-cardano-db-hasura/src/example_queries/rewards/rewardsForAddress.graphql index bf9a3c21..7f0ade54 100644 --- a/packages/api-cardano-db-hasura/src/example_queries/rewards/rewardsForAddress.graphql +++ b/packages/api-cardano-db-hasura/src/example_queries/rewards/rewardsForAddress.graphql @@ -11,5 +11,6 @@ query rewardsForAddress ( earnedIn { number } + type } } diff --git a/packages/api-cardano-db-hasura/test/rewards.query.test.ts b/packages/api-cardano-db-hasura/test/rewards.query.test.ts index e8ea2d86..4d57e90d 100644 --- a/packages/api-cardano-db-hasura/test/rewards.query.test.ts +++ b/packages/api-cardano-db-hasura/test/rewards.query.test.ts @@ -25,6 +25,7 @@ describe('rewards', () => { expect(rewards.length).toBe(5) expect(rewards[0].stakePool.hash).toBeDefined() expect(rewards[0].earnedIn.number).toBeDefined() + expect(rewards[0].type).toBeDefined() }) it('can return aggregated data on all delegations', async () => {