Skip to content

Commit

Permalink
Merge pull request #798 from NewShadesDAO/add-block-info-to-candidate…
Browse files Browse the repository at this point in the history
…-sig

add block info to candidate signatures in the subgraph
  • Loading branch information
solimander authored Oct 9, 2023
2 parents ec6f6c1 + 2391996 commit 2b6d0f2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/nouns-subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,12 @@ type ProposalCandidateSignature @entity {

"Whether this signature has been canceled"
canceled: Boolean!

"The signature's creation timestamp"
createdTimestamp: BigInt!

"The signature's creation block"
createdBlock: BigInt!
}

type ProposalFeedback @entity(immutable: true) {
Expand Down
2 changes: 2 additions & 0 deletions packages/nouns-subgraph/src/nouns-dao-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export function handleSignatureAdded(event: SignatureAdded): void {
candidateSig.encodedProposalHash = event.params.encodedPropHash;
candidateSig.sigDigest = event.params.sigDigest;
candidateSig.reason = event.params.reason;
candidateSig.createdBlock = event.block.number;
candidateSig.createdTimestamp = event.block.timestamp;

candidateSig.save();
}
Expand Down
6 changes: 6 additions & 0 deletions packages/nouns-subgraph/tests/nouns-dao-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ describe('nouns-dao-data', () => {
encodedProposalHash,
sigDigest,
reason,
blockNumber,
blockTimestamp,
);

handleSignatureAdded(event);
Expand All @@ -140,6 +142,8 @@ describe('nouns-dao-data', () => {
assert.bytesEquals(signature.sigDigest, sigDigest);
assert.stringEquals(signature.reason, reason);
assert.booleanEquals(signature.canceled, false);
assert.bigIntEquals(signature.createdBlock, blockNumber);
assert.bigIntEquals(signature.createdTimestamp, blockTimestamp);
});

test('skips signature if encodedProposalHash does not match latest version', () => {
Expand All @@ -158,6 +162,8 @@ describe('nouns-dao-data', () => {
differentEncodedProposalHash,
sigDigest,
reason,
blockNumber,
blockTimestamp,
);

handleSignatureAdded(event);
Expand Down
4 changes: 4 additions & 0 deletions packages/nouns-subgraph/tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,12 @@ export function createSignatureAddedEvent(
encodedPropHash: Bytes,
sigDigest: Bytes,
reason: string,
blockNumber: BigInt,
blockTimestamp: BigInt,
): SignatureAdded {
let newEvent = changetype<SignatureAdded>(newMockEvent());
newEvent.block.timestamp = blockTimestamp;
newEvent.block.number = blockNumber;

newEvent.parameters.push(new ethereum.EventParam('signer', ethereum.Value.fromAddress(signer)));
newEvent.parameters.push(new ethereum.EventParam('sig', ethereum.Value.fromBytes(sig)));
Expand Down

0 comments on commit 2b6d0f2

Please sign in to comment.