aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ticket.js
blob: 2a55ee35c296e0adcbd89e0edc4f98d7b5f47967 (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) => {
	let { ticket } = await get('/ticket');

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

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

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