Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Commit 2f08dde

Browse files
authored
Merge pull request #37 from veqtor/cleanup_dev
Clean up lots of garbage
2 parents de02252 + 5f7e433 commit 2f08dde

File tree

2 files changed

+2
-141
lines changed

2 files changed

+2
-141
lines changed

conseilUtil.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ conseiljs.registerLogger(logger)
99
conseiljs.registerFetch(fetch)
1010
const conseilServer = 'https://conseil-prod.cryptonomic-infra.tech'
1111
const conseilApiKey = 'aa73fa8a-8626-4f43-a605-ff63130f37b1' // signup at nautilus.cloud
12-
const tezosNode = ''
1312
const mainnet = require('./config').networkConfig
1413

1514

@@ -227,12 +226,10 @@ const gethDAOPerTez = async() => {
227226

228227
const getKolibriPerTez = async() => {
229228
const tezBalance = await(getTezBalanceForAddress(mainnet.kolibriSwap))
230-
//console.log("Tez balance", tezBalance)
231229
var kolibriBalance = await(getTokenBalance(mainnet.kolibriLedger, mainnet.kolibriSwap))
230+
231+
// TODO: Find a better way to get the balance, this is FA1.2, mike?
232232
kolibriBalance = parseInt(kolibriBalance.replace("Pair {} ", "")) / (10**((18 - 6)))
233-
//console.log(kolibriBalance)
234-
//console.log(typeof(kolibriBalance))
235-
//console.log("Kol balance", kolibriBalance)
236233
return kolibriBalance / tezBalance
237234
}
238235

@@ -470,11 +467,7 @@ const getFeaturedArtisticUniverse = async(max_time) => {
470467
const getRecommendedCurateDefault = async() => {
471468
hdaoPerTez = await gethDAOPerTez()
472469
kolPerTez = await getKolibriPerTez()
473-
//console.log("hdaoPerTez", hdaoPerTez)
474-
//console.log("kolPerTez", kolPerTez)
475470
hdaoPerKol = hdaoPerTez / kolPerTez
476-
//console.log("hdaoPerKol", hdaoPerKol)
477-
478471
//Minimum of $0.1, 0.1 hDAO, and 0.1tez, in hDAO
479472
return Math.floor(Math.min(hdaoPerKol * 0.1, 0.1, 0.1 * hdaoPerTez) * 1_000_000)
480473
}

index.js

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -15,122 +15,20 @@ const reducer = (accumulator, currentValue) => parseInt(accumulator) + parseInt(
1515

1616
const getIpfsHash = async (ipfsHash) => {
1717
return await axios.get('https://cloudflare-ipfs.com/ipfs/' + ipfsHash).then(res => res.data)
18-
/* const nftDetailJson = await nftDetails.json();
19-
20-
const nftName = nftDetailJson.name;
21-
const nftDescription = nftDetailJson.description;
22-
const nftCreators = nftDetailJson.creators.join(', ');
23-
const nftArtifact = `https://cloudflare-ipfs.com/ipfs/${nftDetailJson.formats[0].uri.toString().slice(7)}`;
24-
const nftArtifactType = nftDetailJson.formats[0].mimeType.toString();
25-
26-
return { name: nftName, description: nftDescription, creators: nftCreators, artifactUrl: nftArtifact, artifactType: nftArtifactType }; */
27-
}
28-
const getObjkts = async () => {
29-
return await axios.get(`https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens`).then(res => res.data)
30-
}
31-
32-
const getTokenHolders = async (tk_id) => {
33-
return await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + tk_id).then(res => res.data)
3418
}
3519

36-
const getTokenHoldersArr = async (arr) => {
37-
38-
return await arr.map(async e => await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + e).then(res => res.data))
39-
/* await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + arr[0]).then(res => console.log(res.data))
40-
*//* var result = arr.map(async e => {
41-
return await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + e).then(res => res.data)
42-
})
43-
44-
console.log(result) */
45-
}
4620

4721
const owners = async (obj) => {
4822
var owners = await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + obj.token_id).then(res => res.data)
4923
var values_arr = (_.values(owners))
5024
obj.total_amount = (values_arr.map(e => parseInt(e))).length > 0 ? values_arr.filter(e => parseInt(e) > 0).reduce(reducer) : 0
5125
obj.owners = owners
52-
// console.log(obj)
53-
//obj.total_amount = (values_arr.map(e => parseInt(e))).reduce(reducer)
5426
return obj
5527
}
5628

57-
const totalAmountIntegral = async (obj) => {
58-
var owners = await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + obj.token_id).then(res => res.data)
59-
// console.log(owners)
60-
var values_arr = (_.values(owners))
61-
obj.total_amount = (values_arr.map(e => parseInt(e))).length > 0 ? (values_arr.filter(e => parseInt(e))) : 0
62-
63-
obj.owners = owners
64-
return obj
65-
}
66-
67-
const objktAmount = async (arr) => {
68-
return await arr.map(e => totalAmountIntegral(e))
69-
//console.log(await getTokenHoldersArr(arr.map(e => _.values(e.token_id)[0])))
70-
}
71-
72-
const objktOwners = async (arr) => {
73-
return await arr.map(e => totalAmountIntegral(e))
74-
}
75-
76-
77-
const getObjktLedger = async () => await axios.get('https://better-call.dev/v1/bigmap/mainnet/511/keys?size=6500').then(res => res.data.map(e => ({ amount: parseInt(e.data.value.value), tz: e.data.key.children[0].value, tk_id: parseInt(e.data.key.children[1].value) })))
78-
const gethDAOLedger = async (counter) => await axios.get('https://api.better-call.dev/v1/bigmap/mainnet/519/keys?size=10&offset=' + counter * 10).then(res => res.data.map(e => {
79-
return { token_id: parseInt(e.data.key.value), hDAO_balance: parseInt(e.data.value.children[0].value) }
80-
}))
81-
82-
//gethDAOLedger()
83-
84-
85-
const getSwaps = async () => {
86-
return await axios.get(`https://api.better-call.dev/v1/bigmap/mainnet/523/keys?size=6000`).then(res => {
87-
return (res.data).map(e => {
88-
var obj = {}
89-
90-
obj['swap_id'] = e.data.key.value
91-
e.data.value != null ? e.data.value.children.map(e => obj[e.name] = e.value) : null
92-
return obj
93-
})
94-
})
95-
}
96-
97-
const merge = (a, b) => {
98-
a.forEach((e1) => {
99-
b.forEach((e2) => {
100-
if (e1.token_id === e2.tk_id) {
101-
_.assign(e1, e2)
102-
}
103-
})
104-
})
105-
return a
106-
}
107-
108-
const mergeSwaps = (arr, swaps) => {
109-
arr.forEach((e1) => {
110-
111-
e1.swaps = []
112-
113-
swaps.forEach((e2) => {
114-
if (parseInt(e1.token_id) === parseInt(e2.objkt_id)) {
115-
e1.swaps.push(e2)
116-
}
117-
})
118-
})
119-
return arr
120-
}
121-
12229
const desc = arr => _.sortBy(arr, e => parseInt(e.objectId)).reverse()
12330
const offset = (arr, set) => arr.slice(set * 30, set * 30 + 30)
12431

125-
const filter = (data, tz) => _.filter(data, (e) => {
126-
if (e.token_info != undefined) {
127-
return e.token_info.creators[0] === tz
128-
}
129-
})
130-
131-
const filterTz = (data, tz) => _.filter(data, { tz: tz })
132-
133-
const test = async () => console.log(desc(await getObjkts()))
13432

13533
const customFloor = function (value, roundTo) {
13634
return Math.floor(value / roundTo) * roundTo;
@@ -144,14 +42,11 @@ const randomFeed = async (counter, res) => {
14442
feed = await feed.map(async e => {
14543
e.token_info = await getIpfsHash(e.ipfsHash)
14644
e.token_id = parseInt(e.objectId)
147-
// console.log(e)
14845
return e
14946
})
15047
var promise = Promise.all(feed.map(e => e))
15148
promise.then(async (results) => {
15249
var aux_arr = results.map(e => e)
153-
//res.set('Cache-Control', `public, max-age=${cache_time}`)
154-
// console.log(aux_arr)
15550
res.json({ result: aux_arr })
15651
})
15752
}
@@ -196,8 +91,6 @@ const getFeed = async (counter, featured) => {
19691
})
19792
}
19893

199-
const filterObjkts = (arr, id_arr) => _.filter(arr, { token_id: tk.id })
200-
20194
const getTzLedger = async (tz, res) => {
20295
/* var ledger = desc(await getObjktLedger())
20396
var objkts = await getObjkts()
@@ -258,8 +151,6 @@ const getTzLedger = async (tz, res) => {
258151
hdao: hdao
259152
})
260153
})
261-
262-
//return tzLedger
263154
}
264155

265156
const getObjktById = async (id, res) => {
@@ -270,20 +161,6 @@ const getObjktById = async (id, res) => {
270161
console.log(objkt)
271162

272163
return objkt
273-
//res.json({ result : objkt })
274-
//var objkts = await getObjkts()
275-
//var swaps = await getSwaps()
276-
//res.json({ result : mergeSwaps([objkt], swaps)[0] })
277-
//console.log(_.filter(mergeSwaps(objkts, swaps), {token_id : id}))
278-
// var arr = await objktOwners(_.filter(mergeSwaps(objkts, swaps), {token_id : id}))
279-
// var promise = Promise.all(arr.map(e => e))
280-
281-
/* promise.then((results) => {
282-
var aux_arr = results.map(e => e)
283-
console.log(aux_arr)
284-
res.json({ result : aux_arr })
285-
}) */
286-
//https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=842
287164
}
288165

289166
const mergehDAO = async (obj) => {
@@ -348,18 +225,9 @@ const getRestrictedObjkts = async () => {
348225
data: list
349226
}
350227
restrictedObjectsLock.release()
351-
// console.log('OBJKT restrictions from NEW')
352228
return list
353229
}
354230

355-
//getObjkts()
356-
//testSwaps()
357-
//getFeed(1)
358-
//getTzLedger('tz1UBZUkXpKGhYsP5KtzDNqLLchwF4uHrGjw')
359-
//getObjktById(15306)
360-
//const test2 = async () => console.log(await getObjktLedger())
361-
//test2()
362-
363231
const app = express()
364232

365233
app.use(express.json())

0 commit comments

Comments
 (0)