Skip to content

Commit

Permalink
fix: empty hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanya-atatakai committed Feb 21, 2025
1 parent d06c106 commit 11c72e1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ type UpdateAgentHash @entity(immutable: true) {

type MechAgent @entity {
id: ID! # uint256
mech: Bytes! # address
mech: Bytes # address
agentHash: Bytes # bytes32
}
16 changes: 13 additions & 3 deletions src/agent-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ export function handleCreateMech(event: CreateMechEvent): void {

entity.save()

let mechAgent = new MechAgent(event.params.agentId.toHexString());
mechAgent.mech = event.params.mech;
mechAgent.save()
let mechAgent = MechAgent.load(event.params.agentId.toHexString());

// Mech is created after agent, which already handles mechAgent creation
// add this check just in case
if (mechAgent !== null) {
mechAgent.mech = event.params.mech;
mechAgent.save()
} else {
mechAgent = new MechAgent(event.params.agentId.toHexString());
mechAgent.mech = event.params.mech;
mechAgent.save()
}


AgentMech.create(event.params.mech);
}
Expand Down
11 changes: 11 additions & 0 deletions src/agent-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ export function handleCreateAgent(event: CreateAgentEvent): void {
entity.transactionHash = event.transaction.hash

entity.save()

let mechAgent = MechAgent.load(event.params.agentId.toHexString());

if (mechAgent !== null) {
mechAgent.agentHash = event.params.agentHash;
mechAgent.save()
} else {
mechAgent = new MechAgent(event.params.agentId.toHexString());
mechAgent.agentHash = event.params.agentHash;
mechAgent.save()
}
}

export function handleManagerUpdated(event: ManagerUpdatedEvent): void {
Expand Down

0 comments on commit 11c72e1

Please sign in to comment.