Skip to content

Commit c10d246

Browse files
committed
Unicly tokens & new latest generator
1 parent 2fc0475 commit c10d246

File tree

55 files changed

+1023
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1023
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
bin/fetch*.js
1+
bin/fetchC*.js
2+
bin/fetchB*.js
23
fallback.png

bin/fetchUnicly.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
const fs = require('fs')
2+
const cp = require('child_process')
3+
const path = require('path')
4+
const axios = require('axios')
5+
const pickBy = require('lodash/pickBy')
6+
const { ethers, InfuraProvider } = require('ethers')
7+
8+
const { exec, readdir, writeFile, promisify } = require('./utils')
9+
10+
const repoPath = '0xLeia/unicly-utoken-info'
11+
const treeURL = `https://api.github.com/repos/${repoPath}/git/trees/main?recursive=1`
12+
const rawURL = `https://raw.githubusercontent.com/${repoPath}/main`
13+
14+
const fns = ['symbol', 'name', 'decimals', '_description']
15+
16+
const abi = fns.map(
17+
name => `function ${name}() view returns (${name === 'decimals' ? 'uint8' : 'string'})`,
18+
)
19+
20+
const provider = new ethers.providers.InfuraProvider(null, process.env.INFURA)
21+
22+
const main = async () => {
23+
const { data } = await axios.get(treeURL)
24+
25+
const files = data.tree.filter(
26+
t => t.path.startsWith('uTokens/0x') && (t.path.endsWith('.json') || t.path.endsWith('svg')),
27+
)
28+
29+
const fileDatas = await Promise.all(
30+
files.map(file => axios.get(`${rawURL}/${file.path}`).then(({ data }) => data)),
31+
)
32+
33+
const contracts = files.reduce((acc, file, i) => {
34+
const [fileName, h] = file.path.split('/').reverse()
35+
const hash = h.toLowerCase()
36+
37+
if (!acc[hash]) {
38+
acc[hash] = {}
39+
}
40+
41+
if (fileName.endsWith('.svg')) {
42+
acc[hash].logo = fileDatas[i]
43+
} else {
44+
acc[hash].data = pickBy(
45+
{
46+
description: (fileDatas[i].description || '').trim().replace(/\s\s+/g, ' '),
47+
website: fileDatas[i].website,
48+
49+
links: pickBy(
50+
{
51+
discord: fileDatas[i].discord,
52+
medium: fileDatas[i].medium,
53+
twitter: fileDatas[i].twitter,
54+
telegram: fileDatas[i].telegram,
55+
},
56+
f => f,
57+
),
58+
},
59+
f => f,
60+
)
61+
}
62+
63+
return acc
64+
}, {})
65+
66+
const contractDatas = await Promise.all(
67+
Object.keys(contracts).map(async hash => {
68+
const erc20 = new ethers.Contract(hash, abi, provider)
69+
const datas = await Promise.all(fns.map(name => erc20[name]().catch(() => null)))
70+
71+
if (!datas[0]) {
72+
return null
73+
}
74+
75+
return pickBy(
76+
fns.reduce((acc, name, i) => {
77+
if (name === 'decimals') {
78+
acc[name] = datas[i]
79+
return acc
80+
}
81+
82+
acc[name.replace(/_/, '')] = (datas[i] || '').trim().replace(/\s\s+/g, ' ')
83+
return acc
84+
}, {}),
85+
f => f,
86+
)
87+
}),
88+
)
89+
90+
const payload = Object.keys(contracts)
91+
.filter((key, i) => contractDatas[i])
92+
.map((key, i) => ({
93+
key,
94+
...contracts[key],
95+
data: { ...contractDatas[i], ...contracts[key].data },
96+
}))
97+
98+
for (const contract of payload) {
99+
const dir = path.join(__dirname, `../data/ethereum/assets/${contract.key}`)
100+
await exec(`mkdir -p ${dir}`)
101+
102+
await writeFile(path.join(dir, 'meta.json'), JSON.stringify(contract.data, null, 2))
103+
104+
const files = await readdir(dir)
105+
if (!files.includes('logo.png')) {
106+
writeFile(path.join(dir, 'logo.svg'), contract.logo)
107+
}
108+
}
109+
}
110+
111+
main()

bin/generate.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,45 @@ const updateMeta = async (path, { skipScore } = {}) => {
104104
return out
105105
}
106106

107+
const getFilters = async () => {
108+
const arg = process.argv[2]
109+
110+
if (!arg) {
111+
const res = await exec('git diff --name-only HEAD HEAD~1 ')
112+
113+
return res.stdout
114+
.split('\n')
115+
.filter(f => f && f.startsWith('data') && f.endsWith('.json'))
116+
.reduce((acc, d) => {
117+
const splits = d.split('/')
118+
119+
if (!acc[splits[1]]) {
120+
acc[splits[1]] = {}
121+
}
122+
123+
acc[splits[1]][splits[3]] = 1
124+
125+
return acc
126+
}, {})
127+
}
128+
129+
if (arg === 'all') {
130+
return {}
131+
}
132+
133+
const splits = arg.split('/')
134+
135+
return {
136+
[splits[0]]: {
137+
[splits[1]]: 1,
138+
},
139+
}
140+
}
141+
107142
const main = async () => {
108143
const chains = (await readdir(ROOT)).filter(d => !d.includes('.'))
109144

110-
const filters = process.argv[2] && process.argv[2].split('/')
145+
const filters = await getFilters()
111146

112147
const full = merge(await loadFull(), {
113148
_symbols: {},
@@ -126,7 +161,7 @@ const main = async () => {
126161
})
127162

128163
for (const chain of chains) {
129-
if (full._remap[chain] || (filters && filters[0] !== chain)) {
164+
if (full._remap[chain] || !filters[chain]) {
130165
continue
131166
}
132167

@@ -155,10 +190,7 @@ const main = async () => {
155190

156191
for (let i = 0; i < assetsLength; ++i) {
157192
const hash = assets[i]
158-
if (
159-
full._remap[`${chain}.${hash}`] ||
160-
(filters && filters[1] && !hash.includes(filters[1]))
161-
) {
193+
if (full._remap[`${chain}.${hash}`] || !get(filters, `${chain}.${hash}`)) {
162194
continue
163195
}
164196

data/ethereum/assets/0x1c468e0d8b0576d659064c6a5b9fee1cba51eee5/logo.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"symbol": "uZODIAC",
3+
"name": "Binance Zodiacs",
4+
"decimals": 18,
5+
"description": "The only full set of 12 limited edition Zodiac NFT characters within The Sandbox game platform. A collection created exclusively for Binance on March 2021 for a $SAND Trading Competition",
6+
"gen": {
7+
"logo": "logo.svg",
8+
"score": 0
9+
}
10+
}

data/ethereum/assets/0x2cd250fa59c0fdc2edf74e1ac8a6db341b959e8d/logo.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"symbol": "uPETS",
3+
"name": "Polkapets Collection (private)",
4+
"decimals": 18,
5+
"description": "A small collection of Polkapets for a test run. If you like it, I will add all of them! :)",
6+
"gen": {
7+
"logo": "logo.svg",
8+
"score": 0
9+
}
10+
}
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"symbol": "uGODTAIL",
3+
"name": "GODTAIL",
4+
"decimals": 18,
5+
"description": "\"Seven Lucky Gods\" is a very auspicious character.",
6+
"gen": {
7+
"logo": "logo.png",
8+
"score": 0
9+
}
10+
}
Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"symbol": "uGOTCHI",
3+
"name": "Aavegotchi Aastronauts",
4+
"decimals": 18,
5+
"description": "The first Aavegotchis bridged to Ethereum!",
6+
"gen": {
7+
"logo": "logo.svg",
8+
"score": 0
9+
}
10+
}

data/ethereum/assets/0x3ac7a71b97183e3db7722c75eaa8df2c1a0badfc/logo.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"symbol": "uWAIFU",
3+
"name": "WAIFU NFT Collection",
4+
"decimals": 18,
5+
"description": "The Official WAIFU NFT Collection, featuring regular additions.",
6+
"links": {
7+
"discord": "https://discord.gg/gBSbXBae3P",
8+
"medium": "https://waifutoken.medium.com",
9+
"twitter": "https://twitter.com/WaifuToken",
10+
"telegram": "t.me/WAIFUToken"
11+
},
12+
"gen": {
13+
"logo": "logo.svg",
14+
"score": 5
15+
}
16+
}
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"symbol": "uUNICLY",
3+
"name": "Unicly Genesis Collection",
4+
"decimals": 18,
5+
"description": "Genesis Unicly Collection by 0xLeia. More Unicly branded NFTs to be added later. This is NOT the UNIC token.",
6+
"website": "https://unic.ly",
7+
"links": {
8+
"discord": "discord.com/invite/uniclyNFT",
9+
"medium": "https://medium.com/@0xleia",
10+
"twitter": "twitter.com/0xLeia",
11+
"telegram": "t.me/LeiaFisherOne"
12+
},
13+
"gen": {
14+
"logo": "logo.svg",
15+
"hasDark": true,
16+
"score": 5
17+
}
18+
}
Loading

data/ethereum/assets/0x44440bd68b5e4b1e0cb810669097e9573175601b/logo.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"symbol": "uARC",
3+
"name": "The Day by ARC",
4+
"decimals": 18,
5+
"description": "The Day, a limited edition collection by Arc for Unicly.",
6+
"gen": {
7+
"logo": "logo.svg",
8+
"hasDark": true,
9+
"score": 0
10+
}
11+
}
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"symbol": "uLEIA",
3+
"name": "Leia Unic",
4+
"decimals": 18,
5+
"description": "Special genesis collection celebrating 0xLeia. This is the first NTF launch collection dedicated to the creator of Unicly.",
6+
"gen": {
7+
"logo": "logo.svg",
8+
"hasDark": true,
9+
"score": 0
10+
}
11+
}

data/ethereum/assets/0x5872e64c3f93363822d2b1e4717be3398fdcea51/logo.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"symbol": "uMASK",
3+
"name": "Hashmask",
4+
"decimals": 18,
5+
"description": "The largest collection of Hashmasks on the market including unique and extra rare pieces.",
6+
"gen": {
7+
"logo": "logo.svg",
8+
"score": 0
9+
}
10+
}

0 commit comments

Comments
 (0)