Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tx to Token1155Holder #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/creator-subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ type Token1155Holder @entity {
lastUpdatedBlock: BigInt!
tokenAndContract: ZoraCreateToken!
balance: BigInt!
txn: TransactionInfo
}

### Protocol Rewards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ function _updateHolderTransfer(
from: Address,
to: Address,
id: BigInt,
value: BigInt
value: BigInt,
txn: string,
): BigInt {
let tokenHolderCountChange = new BigInt(0);
if (!to.equals(Address.zero())) {
Expand All @@ -201,6 +202,7 @@ function _updateHolderTransfer(
} else {
holder.balance = holder.balance.plus(value);
}
holder.txn = txn;
holder.lastUpdatedBlock = blockNumber;
holder.save();
} else {
Expand All @@ -210,6 +212,7 @@ function _updateHolderTransfer(
if (fromHolder) {
fromHolder.balance = fromHolder.balance.minus(value);
fromHolder.lastUpdatedBlock = blockNumber;
fromHolder.txn = txn;
fromHolder.save();
if (fromHolder.balance.equals(BigInt.zero())) {
tokenHolderCountChange = tokenHolderCountChange.minus(new BigInt(1));
Expand Down Expand Up @@ -294,13 +297,15 @@ export function handleUpdatedToken(event: UpdatedToken): void {

// update the minted number and mx number
export function handleTransferSingle(event: TransferSingle): void {
const txn = makeTransaction(event);
const newHolderNumber = _updateHolderTransfer(
event.block.number,
event.address,
event.params.from,
event.params.to,
event.params.id,
event.params.value
event.params.value,
txn
);

const token = ZoraCreateToken.load(
Expand All @@ -327,6 +332,7 @@ export function handleTransferSingle(event: TransferSingle): void {

// update the minted number and max number
export function handleTransferBatch(event: TransferBatch): void {
const txn = makeTransaction(event);
if (event.params.from.equals(Address.zero())) {
for (let i = 0; i < event.params.ids.length; i++) {
const newTokenHolderBalance = _updateHolderTransfer(
Expand All @@ -335,7 +341,8 @@ export function handleTransferBatch(event: TransferBatch): void {
event.params.from,
event.params.to,
event.params.ids[i],
event.params.values[i]
event.params.values[i],
txn
);
const tokenId = getTokenId(event.address, event.params.ids[i]);
const token = ZoraCreateToken.load(tokenId);
Expand All @@ -356,7 +363,8 @@ export function handleTransferBatch(event: TransferBatch): void {
event.params.from,
event.params.to,
event.params.ids[i],
event.params.values[i]
event.params.values[i],
txn
);
const tokenId = getTokenId(event.address, event.params.ids[i]);
const token = ZoraCreateToken.load(tokenId);
Expand All @@ -376,7 +384,8 @@ export function handleTransferBatch(event: TransferBatch): void {
event.params.from,
event.params.to,
event.params.ids[i],
event.params.values[i]
event.params.values[i],
txn
);
const tokenId = getTokenId(event.address, event.params.ids[i]);
const token = ZoraCreateToken.load(tokenId);
Expand Down
4 changes: 2 additions & 2 deletions packages/creator-subgraph/src/constants/chainid.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigInt } from "@graphprotocol/graph-ts";

export const chainid = BigInt.fromI32(8453);
export const network = "base";
export const chainid = BigInt.fromI32(84532);
export const network = "base-sepolia";
Loading