Skip to content

Commit

Permalink
Update TransferFractionToken model fields and mapping logic
Browse files Browse the repository at this point in the history
  • Loading branch information
k.ikemizu committed Jan 9, 2025
1 parent 9ae763c commit 82b413f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 4 additions & 6 deletions pkgs/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}
11 changes: 5 additions & 6 deletions pkgs/subgraph/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 82b413f

Please sign in to comment.