Skip to content

Commit

Permalink
add block number and timestamp to candidate signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
pedropregueiro committed Sep 28, 2023
1 parent 21af7aa commit 2391996
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 @@ -520,6 +520,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 @@ -396,8 +396,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 2391996

Please sign in to comment.