-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnft-activity.ts
56 lines (52 loc) · 1.27 KB
/
nft-activity.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {
array,
literal,
strictObject,
variant,
type InferOutput,
} from "@valibot/valibot";
import {
ActivityLog as Log,
Id,
IsoTimestamp,
Network,
WebhookId,
Erc1155Metadata,
} from "./shared.ts";
import { Address } from "./shared.ts";
import { Hex } from "./shared.ts";
import { Hash } from "./shared.ts";
export type NftActivityErc721Transfer = InferOutput<typeof Erc721Transfer>;
const Erc721Transfer = strictObject({
fromAddress: Address,
toAddress: Address,
contractAddress: Address,
blockNum: Hex,
hash: Hash,
erc721TokenId: Hex,
category: literal("erc721"),
log: Log,
});
export type NftActivityErc1155Transfer = InferOutput<typeof Erc1155Transfer>;
const Erc1155Transfer = strictObject({
fromAddress: Address,
toAddress: Address,
contractAddress: Address,
blockNum: Hex,
hash: Hash,
erc1155Metadata: Erc1155Metadata,
category: literal("erc1155"),
log: Log,
});
export type NftActivityTransfer = InferOutput<typeof Transfers>;
const Transfers = variant("category", [Erc721Transfer, Erc1155Transfer]);
export const NftActivitySchema = strictObject({
webhookId: WebhookId,
id: Id,
createdAt: IsoTimestamp,
type: literal("NFT_ACTIVITY"),
event: strictObject({
network: Network,
activity: array(Transfers),
}),
});