Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tx hash to dao entity in subgraph #590

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/subgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UPCOMING]

## 1.4.1
### Added

## 1.5.0
- Add `txHash` field to the Dao entity.

## 1.4.1

### Changed

Expand Down
1 change: 1 addition & 0 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ type Dao @entity {
daoURI: String
metadata: String
createdAt: BigInt!
txHash: Bytes!
token: ERC20Contract
actions: [Action!]! @derivedFrom(field: "dao")
transfers: [TokenTransfer!]! @derivedFrom(field: "dao")
Expand Down
1 change: 1 addition & 0 deletions packages/subgraph/src/registries/daoRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function handleDAORegistered(event: DAORegistered): void {

entity.creator = event.params.creator;
entity.createdAt = event.block.timestamp;
entity.txHash = event.transaction.hash;

// subscribe to templates
DaoTemplateV1_0_0.create(daoAddress);
Expand Down
2 changes: 2 additions & 0 deletions packages/subgraph/tests/dao/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ export function createDaoEntityState(
daoEntity.creator = Address.fromString(creator);
daoEntity.createdAt = BigInt.zero();
daoEntity.token = Address.fromString(token).toHexString();
// random tx hash for testing purposes only
daoEntity.txHash = Bytes.fromHexString('0x01');
daoEntity.save();

return daoEntity;
Expand Down
2 changes: 2 additions & 0 deletions packages/subgraph/tests/helpers/method-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ class DaoMethods extends Dao {
this.token = Address.fromString(DAO_TOKEN_ADDRESS).toHexString();
this.trustedForwarder = Address.fromHexString(ADDRESS_TWO);
this.signatureValidator = Address.fromHexString(ADDRESS_THREE);
// random tx hash for testing purposes only
this.txHash = Bytes.fromHexString('0x01');
return this;
}

Expand Down
12 changes: 12 additions & 0 deletions packages/subgraph/tests/registry/daoRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ describe('DAORegistry', () => {
'createdAt',
newDaoEvent.block.timestamp.toString()
);
assert.fieldEquals(
'Dao',
daoEntityId,
'txHash',
newDaoEvent.transaction.hash.toHexString()
);
});

test("Don't store subdomain for blocklisted DAO", () => {
Expand Down Expand Up @@ -72,6 +78,12 @@ describe('DAORegistry', () => {
'createdAt',
newDaoEvent.block.timestamp.toString()
);
assert.fieldEquals(
'Dao',
denylistedEntityId,
'txHash',
newDaoEvent.transaction.hash.toHexString()
);

const daoEntity = Dao.load(denylistedEntityId);
assert.assertNull(daoEntity!.subdomain);
Expand Down
Loading