forked from factoria-org/skinnerbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
69 lines (69 loc) · 2.05 KB
/
index.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/web3/1.7.0-rc.0/web3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.7/handlebars.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/f0.js"></script>
<script id="template" type="text/x-handlebars-template">
<img src="{{image}}">
<h1>{{title}}</h1>
<table class='invites'>
<tr>
<th>mint price</th>
<th>mint limit</th>
<th>Invite</th>
</tr>
{{#each items}}
<tr>
<td>{{eth}} ETH</td>
<td>{{limit}}</td>
<td><a class='btn' href="mint.html#address={{address}}&key={{key}}">Go</td</a></td>
</tr>
{{/each}}
</table>
</script>
<script>
const f0 = new F0()
const web3= new Web3(window.ethereum)
const template = Handlebars.compile(document.querySelector("#template").innerHTML);
document.addEventListener("DOMContentLoaded", async () => {
let config = await fetch("box.json").then((r) => {
return r.json()
})
let net = await web3.eth.getChainId()
console.log("net = ", net)
await window.ethereum.send('eth_requestAccounts');
try {
await f0.init({
web3: web3,
contract: config.contract,
network: config.network
})
const name = await f0.name()
const symbol = await f0.symbol()
const placeholder = await f0.placeholder()
const invites = await f0.myInvites()
document.querySelector(".box").innerHTML = template({
title: `${name} (${symbol}) Invite List`,
image: placeholder.converted.image,
items: Object.keys(invites).map((key, index) => {
return {
index: index,
address: config.contract,
key: key,
eth: invites[key].condition.converted.eth,
limit: invites[key].condition.converted.limit
}
})
})
} catch (e) {
document.querySelector(".box").innerHTML = `<h1>${e.message.toLowerCase()}</h1>`
}
})
</script>
</head>
<body>
<div class='box'></div>
</body>
</html>