Skip to content

Commit

Permalink
add expiration to token
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBeardEth committed Dec 15, 2023
1 parent 5a2131a commit ad3b95d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/apibara/src/erc721_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function transferToTask(_header: BlockHeader, { event }: EventWithTransaction) {
const collectionId = Number(BigInt(event.data[2]));
const price = formatUnits(BigInt(event.data[3]).toString(), 18);
const type = Number(BigInt(event.data[7]));

const expiration = Number(BigInt(event.data[4]));
switch (type) {
case OrderActionType.Create:
return {
Expand All @@ -90,6 +90,7 @@ function transferToTask(_header: BlockHeader, { event }: EventWithTransaction) {
},
update: {
price: price,
expiration: expiration,
},
};
case OrderActionType.Edit:
Expand All @@ -102,6 +103,7 @@ function transferToTask(_header: BlockHeader, { event }: EventWithTransaction) {
},
update: {
price: price,
expiration: expiration,
},
};
case OrderActionType.Accept:
Expand All @@ -114,6 +116,7 @@ function transferToTask(_header: BlockHeader, { event }: EventWithTransaction) {
},
update: {
price: undefined,
expiration: undefined,
},
};
case OrderActionType.Cancel:
Expand All @@ -126,6 +129,7 @@ function transferToTask(_header: BlockHeader, { event }: EventWithTransaction) {
},
update: {
price: undefined,
expiration: undefined,
},
};
default: {
Expand Down
3 changes: 2 additions & 1 deletion packages/db/schema/erc721_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const erc721Tokens = pgSqlTable("erc721_tokens", {
owner: text("owner"),
image: text("image"),
name: text("name"),
//price: numeric("price"),
price: numeric("price"),
expiration: integer("expiration"),
//lastPrice: numeric('last_price'),
metadata: json("metadata").$type<{
attributes:
Expand Down

0 comments on commit ad3b95d

Please sign in to comment.