Skip to content

Commit

Permalink
Merge pull request #121 from Aut-Labs/autid_create_fix
Browse files Browse the repository at this point in the history
Autid create fix
  • Loading branch information
mrtmeeseeks authored Sep 30, 2024
2 parents c9d7b50 + 9158929 commit 729cdb0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
16 changes: 14 additions & 2 deletions subgraphs/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type AutID @entity(immutable: false) {
tokenID: BigInt!
username: String!
metadataUri: String
metadataJson: String
# metadataJson: String
joinedHubs: [HubJoinedInfo!] @derivedFrom(field: "autID")
blockNumber: BigInt!
blockTimestamp: BigInt!
Expand Down Expand Up @@ -61,10 +61,22 @@ type Contribution @entity {
type Task @entity {
id: ID!
metadataUri: String!
metadataJson: String
# metadataJson: String
taskId: Bytes!
creator: Bytes!
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}

type HubAdmin @entity {
id: ID!
hubAddress: Bytes!
autID: AutID!
}

type HubMember @entity {
id: ID!
hubAddress: Bytes!
autID: AutID!
}
2 changes: 1 addition & 1 deletion subgraphs/src/aut-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function handleRecordCreated(event: RecordCreated): void {
autID.blockNumber = event.block.number;
autID.blockTimestamp = event.block.timestamp;
autID.transactionHash = event.transaction.hash;
autID.metadataJson = fetchMetadataFromIpfs(event.params.uri);
// autID.metadataJson = fetchMetadataFromIpfs(event.params.uri);

autID.save();
}
Expand Down
21 changes: 20 additions & 1 deletion subgraphs/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ import {
MarketSet,
MetadataUriSet,
ArchetypeSet,
AdminGranted,
} from "../generated/Hub/Hub";
import { Hub } from "../generated/schema";
import { Hub, HubAdmin } from "../generated/schema";
import { BigInt } from "@graphprotocol/graph-ts";

export function handleAdminGranted(event: AdminGranted): void {
let id = event.params.to.toHexString();
let hubAdmin = HubAdmin.load(id);
if (hubAdmin == null) {
hubAdmin = new HubAdmin(id);
}
hubAdmin.autID = id;
hubAdmin.hubAddress = event.params.hubAddress;
hubAdmin.save();
}

export function handleHubCreated(event: HubCreated): void {
let id = event.params.hubAddress.toHexString();
let hub = Hub.load(id);
Expand All @@ -21,6 +33,13 @@ export function handleHubCreated(event: HubCreated): void {
hub.minCommitment = event.params.commitment;
hub.domain = '';

// Create a new HubAdmin entity
let autIDAddress = event.params.deployer.toHexString();
let hubAdmin = new HubAdmin(autIDAddress);
hubAdmin.autID = autIDAddress;
hubAdmin.hubAddress = hub.address;
hubAdmin.save();

// system
hub.blockNumber = event.block.number;
hub.blockTimestamp = event.block.timestamp;
Expand Down
4 changes: 2 additions & 2 deletions subgraphs/src/task-registry.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Task } from '../generated/schema'
import { RegisterTask } from '../generated/TaskRegistry/TaskRegistry'
import { fetchMetadataFromIpfs } from './fetch-metadata';
// import { fetchMetadataFromIpfs } from './fetch-metadata';

export function handleRegisterTask(event: RegisterTask): void {
let task = new Task(event.params.taskId.toHexString())
task.metadataUri = event.params.uri;
task.metadataJson = fetchMetadataFromIpfs(event.params.uri);
// task.metadataJson = fetchMetadataFromIpfs(event.params.uri);
task.taskId = event.params.taskId;
task.creator = event.params.who;
task.blockNumber = event.block.number;
Expand Down
2 changes: 2 additions & 0 deletions subgraphs/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ dataSources:
handler: handleCommitmentSet
- event: MarketSet(uint256)
handler: handleMarketSet
# - event: AdminGranted(address,address)
# handler: handleAdminGranted
file: ./src/hub.ts
- kind: ethereum
name: HubDomainsRegistry
Expand Down

0 comments on commit 729cdb0

Please sign in to comment.