Skip to content

Commit

Permalink
feat: tokenOwner as Avatar entity
Browse files Browse the repository at this point in the history
  • Loading branch information
vibern0 committed Nov 4, 2024
1 parent cdfc081 commit c682bcc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,5 @@ type Token {
transactionHash: String!
version: Int!
tokenType: TokenType!
tokenOwner: String!
tokenOwner: Avatar!
}
30 changes: 9 additions & 21 deletions src/common/handleTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export const handleTransfer = async ({
transferType: TransferType_t;
version: number;
}) => {
let isWrapped = transferType === "Erc20WrapperTransfer";

for (let i = 0; i < tokens.length; i++) {
const token = await context.Token.get(tokens[i]);
if (!token) {
Expand All @@ -51,7 +49,7 @@ export const handleTransfer = async ({
// TODO: fix
tokenType: "RegisterHuman",
// TODO: fix
tokenOwner: event.params.to,
tokenOwner_id: event.params.to,
});
}

Expand All @@ -74,24 +72,14 @@ export const handleTransfer = async ({
};
context.Transfer.set(transferEntity);

await updateAvatarBalance(
context,
values[i],
event.block.timestamp,
{
id: event.params.to,
token_id: tokens[i],
}
);
await updateAvatarBalance(
context,
-values[i],
event.block.timestamp,
{
id: event.params.from,
token_id: tokens[i],
},
);
await updateAvatarBalance(context, values[i], event.block.timestamp, {
id: event.params.to,
token_id: tokens[i],
});
await updateAvatarBalance(context, -values[i], event.block.timestamp, {
id: event.params.from,
token_id: tokens[i],
});
await incrementStats(context, "transfers");
}
};
2 changes: 1 addition & 1 deletion src/event_handlers/hubV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ERC20Lift.ERC20WrapperDeployed.handler(async ({ event, context }) => {
event.params.circlesType === 0n
? "WrappedDemurrageToken"
: "WrappedStaticToken",
tokenOwner: event.params.avatar,
tokenOwner_id: event.params.avatar,
});
});

Expand Down

0 comments on commit c682bcc

Please sign in to comment.