From 82b413fc7ca59c398f220ed191a165e4d73c5336 Mon Sep 17 00:00:00 2001 From: "k.ikemizu" Date: Thu, 9 Jan 2025 20:11:04 +0900 Subject: [PATCH] Update TransferFractionToken model fields and mapping logic --- pkgs/subgraph/schema.graphql | 10 ++++------ pkgs/subgraph/src/mapping.ts | 11 +++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkgs/subgraph/schema.graphql b/pkgs/subgraph/schema.graphql index 9381afb..ec30ef8 100644 --- a/pkgs/subgraph/schema.graphql +++ b/pkgs/subgraph/schema.graphql @@ -20,13 +20,11 @@ type InitializedFractionToken @entity { type TransferFractionToken @entity { id: ID! - from: String! - to: String! - tokenId: BigInt! - amount: BigInt! workspaceId: ID! + holderAddress: String! hatId: BigInt! wearer: String! - blockTimestamp: BigInt! - blockNumber: BigInt! + tokenId: BigInt! + balance: BigInt! + updatedAt: BigInt! } diff --git a/pkgs/subgraph/src/mapping.ts b/pkgs/subgraph/src/mapping.ts index 6f199a6..06b45a4 100644 --- a/pkgs/subgraph/src/mapping.ts +++ b/pkgs/subgraph/src/mapping.ts @@ -59,15 +59,14 @@ export function handleTransferSingle(ev: TransferSingle): void { ); let transfer = new TransferFractionToken(id); - transfer.from = ev.params.from.toHex(); - transfer.to = ev.params.to.toHex(); - transfer.tokenId = ev.params.id; - transfer.amount = ev.params.value; + transfer.id = `${ev.address}${ev.params.id}`; transfer.workspaceId = ""; + transfer.holderAddress = ev.params.from.toHex(); transfer.hatId = BigInt.fromString("0"); transfer.wearer = ""; - transfer.blockNumber = ev.block.number; - transfer.blockTimestamp = ev.block.timestamp; + transfer.tokenId = ev.params.id; + transfer.balance = ev.params.value; // TODO: 送金前の残高から送金額のvalueを引く + transfer.updatedAt = ev.block.timestamp; if (initializedFractionToken) { transfer.workspaceId = initializedFractionToken.workspaceId;