A Prediction Market on the AT Protocol
1import { parse } from "@atcute/lexicons";
2import { it, expect } from "vitest";
3import { ZaCoCiaranCumulusResolution } from "../../generated/typescript";
4import * as CID from "@atcute/cid";
5import * as TID from "@atcute/tid";
6import { Lexicon } from "@/core/constants";
7import { createUri } from "@/core/utils";
8
9const tid = TID.now();
10const cid = await CID.create(0x71, new Uint8Array([10]))
11
12const data = {
13 $type: Lexicon.RESOLUTION,
14 market: {
15 cid: CID.toString(cid),
16 uri: createUri("did:plc:example", Lexicon.MARKET, tid),
17 },
18 answer: "yes",
19 createdAt: "2026-02-25T11:52:33.278Z",
20}
21
22it("resolution schema validation", () => {
23 const resolution = parse(ZaCoCiaranCumulusResolution.mainSchema, data);
24 expect(resolution.$type).toEqual(Lexicon.RESOLUTION);
25 expect(resolution.market).toEqual({
26 cid: CID.toString(cid),
27 uri: createUri("did:plc:example", Lexicon.MARKET, tid),
28 });
29 expect(resolution.answer).toEqual("yes");
30 expect(resolution.createdAt).toEqual("2026-02-25T11:52:33.278Z");
31});