From 3c70db7eb37fc0eadea6c671e4832bb558bc98a0 Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Wed, 18 Oct 2023 13:43:20 -0300 Subject: [PATCH] refactor: rename delegate fields for clarity --- subgraphs/venus-governance/schema.graphql | 4 ++-- .../venus-governance/src/operations/update.ts | 2 +- .../integration/queries/delegateByIdQuery.graphql | 2 +- .../integration/queries/delegatesQuery.graphql | 4 ++-- .../venus-governance/tests/integration/xvsVault.ts | 14 +++++++------- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/subgraphs/venus-governance/schema.graphql b/subgraphs/venus-governance/schema.graphql index c8eb3bb2..85413e1d 100644 --- a/subgraphs/venus-governance/schema.graphql +++ b/subgraphs/venus-governance/schema.graphql @@ -20,10 +20,10 @@ type Delegate @entity { delegateCount: Int! "Accounts delegating to this voter" - delegates: [Delegate!]! @derivedFrom(field: "delegate") + delegators: [Delegate!]! @derivedFrom(field: "delegatee") "Id of account receiving this accounts delegation" - delegate: Delegate + delegatee: Delegate "Votes that a delegate has made in different proposals" votes: [Vote!]! @derivedFrom(field: "voter") diff --git a/subgraphs/venus-governance/src/operations/update.ts b/subgraphs/venus-governance/src/operations/update.ts index c5d8ccb4..8abdc3f7 100644 --- a/subgraphs/venus-governance/src/operations/update.ts +++ b/subgraphs/venus-governance/src/operations/update.ts @@ -51,7 +51,7 @@ export function updateDelegateChanged(event: E): void { const delegatorResult = getOrCreateDelegate(delegator); const delegatorEntity = delegatorResult.entity; - delegatorEntity.delegate = toDelegate; + delegatorEntity.delegatee = toDelegate; delegatorEntity.save(); if (fromDelegate != nullAddress.toHexString()) { diff --git a/subgraphs/venus-governance/tests/integration/queries/delegateByIdQuery.graphql b/subgraphs/venus-governance/tests/integration/queries/delegateByIdQuery.graphql index 27a7cb99..35815ecc 100644 --- a/subgraphs/venus-governance/tests/integration/queries/delegateByIdQuery.graphql +++ b/subgraphs/venus-governance/tests/integration/queries/delegateByIdQuery.graphql @@ -7,7 +7,7 @@ query DelegateById($id: ID!) { delegate { id } - delegates { + delegators { id } votes { diff --git a/subgraphs/venus-governance/tests/integration/queries/delegatesQuery.graphql b/subgraphs/venus-governance/tests/integration/queries/delegatesQuery.graphql index b7b578f8..0c669c22 100644 --- a/subgraphs/venus-governance/tests/integration/queries/delegatesQuery.graphql +++ b/subgraphs/venus-governance/tests/integration/queries/delegatesQuery.graphql @@ -4,10 +4,10 @@ query Delegates { stakedXvsMantissa totalVotesMantissa delegateCount - delegate { + delegatee { id } - delegates { + delegators { id } votes { diff --git a/subgraphs/venus-governance/tests/integration/xvsVault.ts b/subgraphs/venus-governance/tests/integration/xvsVault.ts index 9b1ca476..c8f9f05e 100644 --- a/subgraphs/venus-governance/tests/integration/xvsVault.ts +++ b/subgraphs/venus-governance/tests/integration/xvsVault.ts @@ -68,8 +68,8 @@ describe('XVS Vault and Delegation', function () { } = await subgraphClient.getDelegateById(user1.address.toLowerCase()); expect(delegate1.delegateCount).to.equal(0); - expect(delegate1.delegate.id).to.equal(user2.address.toLowerCase()); - expect(delegate1.delegates).to.deep.equal([]); + expect(delegate1.delegatee.id).to.equal(user2.address.toLowerCase()); + expect(delegate1.delegators).to.deep.equal([]); expect(delegate1.stakedXvsMantissa).to.deep.equal(amount.toFixed()); expect(delegate1.totalVotesMantissa).to.equal('0'); @@ -79,7 +79,7 @@ describe('XVS Vault and Delegation', function () { } = await subgraphClient.getDelegateById(user2.address.toLowerCase()); expect(delegate2.delegateCount).to.equal(1); - expect(delegate2.delegates).to.deep.equal([{ id: user1.address, __typename: 'Delegate' }]); + expect(delegate2.delegators).to.deep.equal([{ id: user1.address, __typename: 'Delegate' }]); expect(delegate2.stakedXvsMantissa).to.equal('0'); expect(delegate2.totalVotesMantissa).to.equal(amount.toFixed()); }); @@ -118,7 +118,7 @@ describe('XVS Vault and Delegation', function () { expect(delegate1.stakedXvsMantissa).to.equal(amount.times(2).toFixed()); expect(delegate1.totalVotesMantissa).to.equal('0'); - expect(delegate1.delegate.id).to.equal(user3.address.toLowerCase()); + expect(delegate1.delegatee.id).to.equal(user3.address.toLowerCase()); const { data: { delegate: delegate2 }, @@ -127,14 +127,14 @@ describe('XVS Vault and Delegation', function () { expect(delegate2.stakedXvsMantissa).to.equal('0'); expect(delegate2.totalVotesMantissa).to.equal('0'); expect(delegate2.delegateCount).to.equal(0); - expect(delegate2.delegates).to.deep.equal([]); + expect(delegate2.delegators).to.deep.equal([]); const { data: { delegate: delegate3 }, } = await subgraphClient.getDelegateById(user3.address.toLowerCase()); expect(delegate3.delegateCount).to.equal(1); - expect(delegate3.delegates).to.deep.equal([ + expect(delegate3.delegators).to.deep.equal([ { id: user1.address.toLowerCase(), __typename: 'Delegate' }, ]); expect(delegate3.stakedXvsMantissa).to.equal(amount.toFixed()); @@ -151,7 +151,7 @@ describe('XVS Vault and Delegation', function () { } = await subgraphClient.getDelegateById(user1.address.toLowerCase()); expect(delegate1.delegateCount).to.equal(1); - expect(delegate1.delegates).to.deep.equal([ + expect(delegate1.delegators).to.deep.equal([ { id: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', __typename: 'Delegate',