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

Commit 142ab4b

Browse files
committed
notforsale
1 parent 3cb6ed3 commit 142ab4b

File tree

2 files changed

+32
-37
lines changed

2 files changed

+32
-37
lines changed

index.js

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ const express = require('express')
44
const cors = require('cors')
55
const _ = require('lodash')
66
const conseilUtil = require('./conseilUtil')
7-
const cls = require('cloud-local-storage')
87
require('dotenv').config()
98

10-
const reducer = (accumulator, currentValue) => accumulator + currentValue;
9+
const reducer = (accumulator, currentValue) => parseInt(accumulator) + parseInt(currentValue)
1110

1211
const getIpfsHash = async (ipfsHash) => {
1312

@@ -35,16 +34,17 @@ const getTokenHoldersArr = async (arr) => {
3534
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))
3635
/* await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + arr[0]).then(res => console.log(res.data))
3736
*//* var result = arr.map(async e => {
38-
return await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + e).then(res => res.data)
39-
})
37+
return await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + e).then(res => res.data)
38+
})
4039
41-
console.log(result) */
40+
console.log(result) */
4241
}
4342

4443
const owners = async (obj) => {
4544
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)
4645
var values_arr = (_.values(owners))
4746
console.log(owners)
47+
obj.total_amount = values_arr.filter(e => parseInt(e) >= 0).reduce(reducer)
4848
obj.owners = owners
4949
console.log(obj)
5050
//obj.total_amount = (values_arr.map(e => parseInt(e))).reduce(reducer)
@@ -137,10 +137,10 @@ const ONE_MINUTE_MILLIS = 60 * 1000
137137

138138
const getFeed = async (counter, res) => {
139139

140-
/* const now_time = Date.now()
141-
const immutable = (typeof max_time !== 'undefined') && (max_time < now_time)
142-
max_time = (typeof max_time !== 'undefined') ? max_time : customFloor(now_time, ONE_MINUTE_MILLIS)
143-
*/
140+
/* const now_time = Date.now()
141+
const immutable = (typeof max_time !== 'undefined') && (max_time < now_time)
142+
max_time = (typeof max_time !== 'undefined') ? max_time : customFloor(now_time, ONE_MINUTE_MILLIS)
143+
*/
144144
var arr = await conseilUtil.getArtisticUniverse(0)
145145

146146
var feed = offset(desc(arr), counter)
@@ -152,13 +152,13 @@ const getFeed = async (counter, res) => {
152152
return e
153153
})
154154
//console.log(feed)
155-
/* var cache_time
156-
if (immutable) {
157-
cache_time = 60 * 10
158-
}
159-
else {
160-
cache_time = (int)(((max_time + ONE_MINUTE_MILLIS) - now_time) / 1000)
161-
} */
155+
/* var cache_time
156+
if (immutable) {
157+
cache_time = 60 * 10
158+
}
159+
else {
160+
cache_time = (int)(((max_time + ONE_MINUTE_MILLIS) - now_time) / 1000)
161+
} */
162162
var promise = Promise.all(feed.map(e => e))
163163
promise.then(async (results) => {
164164
var aux_arr = results.map(e => e)
@@ -169,9 +169,8 @@ const getFeed = async (counter, res) => {
169169
res.json({ result: aux_arr })
170170
})
171171
}
172-
//getFeed(1)
172+
173173
const filterObjkts = (arr, id_arr) => _.filter(arr, { token_id: tk.id })
174-
//console.log(_.find(ledger, { tz : 'KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9'}))
175174

176175
const getTzLedger = async (tz, res) => {
177176
/* var ledger = desc(await getObjktLedger())
@@ -263,7 +262,7 @@ const hDAOFeed = async (counter, res) => {
263262
//testSwaps()
264263
//getFeed(0)
265264
//getTzLedger('tz1UBZUkXpKGhYsP5KtzDNqLLchwF4uHrGjw')
266-
//getObjktById(6246)
265+
//getObjktById(5965)
267266
//const test2 = async () => console.log(await getObjktLedger())
268267
//test2()
269268

@@ -273,17 +272,20 @@ app.use(express.json())
273272
app.use(cors({ origin: '*' }))
274273

275274
app.post('/feed', async (req, res) => {
276-
/* var counter = req.query.counter
277-
var max_time = req.query.hasOwnProperty('time') ? customFloor(req.query.time, ONE_MINUTE_MILLIS) : null
278-
const now_time_qt = customFloor(Date.now(), ONE_MINUTE_MILLIS)
279-
if (max_time != null & max_time > now_time_qt) {
280-
max_time = null
281-
} */
275+
/*
276+
var counter = req.query.counter
277+
var max_time = req.query.hasOwnProperty('time') ? customFloor(req.query.time, ONE_MINUTE_MILLIS) : null
278+
const now_time_qt = customFloor(Date.now(), ONE_MINUTE_MILLIS)
279+
if (max_time != null & max_time > now_time_qt) {
280+
max_time = null
281+
}
282+
*/
282283
await getFeed(req.body.counter, res)
283284
})
284285

285286
app.post('/tz', async (req, res) => {
286-
console.log(req.body.tz)
287+
288+
// list of restricted addresses
287289
var list = await axios.get('https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/w.json').then(res => res.data)
288290

289291
list.includes(req.body.tz)
@@ -295,6 +297,8 @@ app.post('/tz', async (req, res) => {
295297
})
296298

297299
app.post('/objkt', async (req, res) => {
300+
301+
// list of restricted objkts
298302
var list = await axios.get('https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/o.json').then(res => res.data)
299303

300304
list.includes(parseInt(req.body.objkt_id))
@@ -308,13 +312,6 @@ app.post('/hdao', async (req, res) => {
308312
await hDAOFeed(parseInt(req.body.counter), res)
309313
})
310314

311-
//app.listen(3001)
312-
module.exports.handler = serverless(app)
315+
app.listen(3001)
316+
//module.exports.handler = serverless(app)
313317

314-
/* const test2 = async () => {
315-
await axios.get('https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/o.json').then(res => console.log(res.data))
316-
}
317-
test2() */
318-
//testTkHolder([{'kt' : 2020}, {'kt' : 2021}])
319-
//getFeed(1)
320-
//getObjktById(2000)

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
"homepage": "https://github.com/hicetnunc2000/hicetnunc#readme",
1919
"dependencies": {
2020
"axios": "^0.21.1",
21-
"cloud-local-storage": "0.0.11",
2221
"conseiljs": "5.0.7-2",
2322
"cors": "^2.8.5",
2423
"dotenv": "^8.2.0",
2524
"express": "^4.17.1",
26-
"fetch": "^1.1.0",
2725
"lodash": "^4.17.21",
2826
"loglevel": "1.7.1",
2927
"node-fetch": "2.6.1",

0 commit comments

Comments
 (0)