Skip to content

Commit

Permalink
refactor: rename delegate fields for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Oct 18, 2023
1 parent 7f40eb2 commit 3c70db7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions subgraphs/venus-governance/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/venus-governance/src/operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function updateDelegateChanged<E>(event: E): void {

const delegatorResult = getOrCreateDelegate(delegator);
const delegatorEntity = delegatorResult.entity;
delegatorEntity.delegate = toDelegate;
delegatorEntity.delegatee = toDelegate;
delegatorEntity.save();

if (fromDelegate != nullAddress.toHexString()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ query DelegateById($id: ID!) {
delegate {
id
}
delegates {
delegators {
id
}
votes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ query Delegates {
stakedXvsMantissa
totalVotesMantissa
delegateCount
delegate {
delegatee {
id
}
delegates {
delegators {
id
}
votes {
Expand Down
14 changes: 7 additions & 7 deletions subgraphs/venus-governance/tests/integration/xvsVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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());
});
Expand Down Expand Up @@ -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 },
Expand All @@ -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());
Expand All @@ -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',
Expand Down

0 comments on commit 3c70db7

Please sign in to comment.