-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathfactory_metadata.py
69 lines (57 loc) · 1.88 KB
/
factory_metadata.py
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
from __future__ import annotations
import asyncio
import csv
import sys
from secrets import token_bytes
from typing import Any
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.util.bech32m import encode_puzzle_hash
from faker import Faker
fake = Faker()
async def create_nft_sample(has_targets: bool) -> list[Any]:
sample = [
bytes32(token_bytes(32)).hex(), # data_hash
fake.image_url(), # data_url
bytes32(token_bytes(32)).hex(), # metadata_hash
fake.url(), # metadata_url
bytes32(token_bytes(32)).hex(), # license_hash
fake.url(), # license_url
1, # edition_number
1, # edition_count
]
if has_targets:
sample.append(encode_puzzle_hash(bytes32(token_bytes(32)), "txch"))
return sample
async def create_target_sample() -> list[Any]:
return [encode_puzzle_hash(bytes32(token_bytes(32)), "txch")]
async def main(count: int, has_targets: bool) -> None:
header = [
"hash",
"uris",
"meta_hash",
"meta_uris",
"license_hash",
"license_uris",
"edition_number",
"edition_total",
]
if has_targets:
header.append("target")
coros = [create_nft_sample(has_targets) for _ in range(count)]
data = await asyncio.gather(*coros)
with open("metadata.csv", "w") as f:
writer = csv.writer(f)
writer.writerows([header, *data])
royalty_address = encode_puzzle_hash(bytes32(token_bytes(32)), "txch")
royalty_basis_pts = 300
print(f"Royalty Address: {royalty_address}")
print(f"Royalty Percent: {royalty_basis_pts}")
if __name__ == "__main__":
params = sys.argv[1:]
if "t" in params:
has_targets = True
count = int(next(iter(set(params) - set("t"))))
else:
has_targets = False
count = int(params[0])
asyncio.run(main(count, has_targets))