aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ticket.ts
blob: 0d93f39071d512af4c2de528e2d97acaf0882601 (plain) (blame)
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
import { auth, get, post } from "$lib/utils";
import { env } from "$env/dynamic/private";
import tickets from "$lib/tickets";

export const createTicket = async (cookies, username) => {
	const { ticket } = await get("/ticket");

	const { address } = await post(
		`/${username}/invoice`,
		{ invoice: { network: "liquid" }, user: { username } },
		auth(cookies),
	);

	const { asset } = await post(
		"/assets",
		{
			address,
			name: `Launch Party Ticket ${ticket}`,
			ticker: "LPT",
			precision: 0,
			asset_amount: "1",
			token_amount: 0,
			domain: "coinos.io",
			filename: tickets[ticket],
		},
		{ authorization: `Bearer ${env.LAUNCH}` },
	);

	await post("/ticket", { asset }, { authorization: `Bearer ${env.LAUNCH}` });
	return asset;
};