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

Commit e29b094

Browse files
authored
Merge branch 'master' into edge_cache_feed
2 parents a993f13 + 9f3302f commit e29b094

File tree

8 files changed

+89
-30
lines changed

8 files changed

+89
-30
lines changed

.env

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
REACT_APP_FEED='http://localhost:3001/feed'
2-
REACT_APP_TZ='http://localhost:3001/tz'
3-
REACT_APP_OBJKT='http://localhost:3001/objkt'
1+
TIMESTAMP=''
2+
BUFFER=''

.serverless/cloudformation-template-update-stack.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
"S3Bucket": {
147147
"Ref": "ServerlessDeploymentBucket"
148148
},
149-
"S3Key": "serverless/hicetnunc-apiv2/dev/1615880662823-2021-03-16T07:44:22.823Z/hicetnunc-apiv2.zip"
149+
"S3Key": "serverless/hicetnunc-apiv2/dev/1616044842570-2021-03-18T05:20:42.570Z/hicetnunc-apiv2.zip"
150150
},
151151
"FunctionName": "hicetnunc-apiv2-dev-handler",
152152
"Handler": "index.handler",
@@ -164,14 +164,14 @@
164164
"HandlerLogGroup"
165165
]
166166
},
167-
"HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E": {
167+
"HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA": {
168168
"Type": "AWS::Lambda::Version",
169169
"DeletionPolicy": "Retain",
170170
"Properties": {
171171
"FunctionName": {
172172
"Ref": "HandlerLambdaFunction"
173173
},
174-
"CodeSha256": "A5PEtCLwbB+fMx1VYq50HcNNaaGwfrVhq2LCEwgYZbk="
174+
"CodeSha256": "XzPgs+74v32jD1VtT3EQIuiguzI/+h1FI5G32MCoFNc="
175175
}
176176
},
177177
"ApiGatewayRestApi": {
@@ -383,7 +383,7 @@
383383
"MethodResponses": []
384384
}
385385
},
386-
"ApiGatewayDeployment1615880658144": {
386+
"ApiGatewayDeployment1616044838303": {
387387
"Type": "AWS::ApiGateway::Deployment",
388388
"Properties": {
389389
"RestApiId": {
@@ -445,7 +445,7 @@
445445
"HandlerLambdaFunctionQualifiedArn": {
446446
"Description": "Current Lambda function version",
447447
"Value": {
448-
"Ref": "HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E"
448+
"Ref": "HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA"
449449
}
450450
},
451451
"ServiceEndpoint": {

.serverless/hicetnunc-apiv2.zip

30.7 KB
Binary file not shown.

.serverless/serverless-state.json

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
"S3Bucket": {
160160
"Ref": "ServerlessDeploymentBucket"
161161
},
162-
"S3Key": "serverless/hicetnunc-apiv2/dev/1615880662823-2021-03-16T07:44:22.823Z/hicetnunc-apiv2.zip"
162+
"S3Key": "serverless/hicetnunc-apiv2/dev/1616044842570-2021-03-18T05:20:42.570Z/hicetnunc-apiv2.zip"
163163
},
164164
"FunctionName": "hicetnunc-apiv2-dev-handler",
165165
"Handler": "index.handler",
@@ -177,14 +177,14 @@
177177
"HandlerLogGroup"
178178
]
179179
},
180-
"HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E": {
180+
"HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA": {
181181
"Type": "AWS::Lambda::Version",
182182
"DeletionPolicy": "Retain",
183183
"Properties": {
184184
"FunctionName": {
185185
"Ref": "HandlerLambdaFunction"
186186
},
187-
"CodeSha256": "A5PEtCLwbB+fMx1VYq50HcNNaaGwfrVhq2LCEwgYZbk="
187+
"CodeSha256": "XzPgs+74v32jD1VtT3EQIuiguzI/+h1FI5G32MCoFNc="
188188
}
189189
},
190190
"ApiGatewayRestApi": {
@@ -396,7 +396,7 @@
396396
"MethodResponses": []
397397
}
398398
},
399-
"ApiGatewayDeployment1615880658144": {
399+
"ApiGatewayDeployment1616044838303": {
400400
"Type": "AWS::ApiGateway::Deployment",
401401
"Properties": {
402402
"RestApiId": {
@@ -458,7 +458,7 @@
458458
"HandlerLambdaFunctionQualifiedArn": {
459459
"Description": "Current Lambda function version",
460460
"Value": {
461-
"Ref": "HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E"
461+
"Ref": "HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA"
462462
}
463463
},
464464
"ServiceEndpoint": {
@@ -616,7 +616,7 @@
616616
"memory": 1024,
617617
"runtime": "nodejs12.x",
618618
"vpc": {},
619-
"versionLogicalId": "HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E"
619+
"versionLogicalId": "HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA"
620620
}
621621
},
622622
"configValidationMode": "warn",
@@ -1010,6 +1010,45 @@
10101010
"node_modules/big-integer/package.json",
10111011
"node_modules/big-integer/README.md",
10121012
"node_modules/big-integer/tsconfig.json",
1013+
"node_modules/dotenv/CHANGELOG.md",
1014+
"node_modules/dotenv/config.js",
1015+
"node_modules/dotenv/lib/cli-options.js",
1016+
"node_modules/dotenv/lib/env-options.js",
1017+
"node_modules/dotenv/lib/main.js",
1018+
"node_modules/dotenv/LICENSE",
1019+
"node_modules/dotenv/package.json",
1020+
"node_modules/dotenv/README.md",
1021+
"node_modules/dotenv/types/index.d.ts",
1022+
"node_modules/dotenv/types/test.ts",
1023+
"node_modules/dotenv/types/tsconfig.json",
1024+
"node_modules/dotenv/types/tslint.json",
1025+
"node_modules/cloud-local-storage/lib/commands/create.d.ts",
1026+
"node_modules/cloud-local-storage/lib/commands/create.js",
1027+
"node_modules/cloud-local-storage/lib/commands/get-all-keys.d.ts",
1028+
"node_modules/cloud-local-storage/lib/commands/get-all-keys.js",
1029+
"node_modules/cloud-local-storage/lib/commands/get-item.d.ts",
1030+
"node_modules/cloud-local-storage/lib/commands/get-item.js",
1031+
"node_modules/cloud-local-storage/lib/commands/init.d.ts",
1032+
"node_modules/cloud-local-storage/lib/commands/init.js",
1033+
"node_modules/cloud-local-storage/lib/commands/list.d.ts",
1034+
"node_modules/cloud-local-storage/lib/commands/list.js",
1035+
"node_modules/cloud-local-storage/lib/commands/reset-password.d.ts",
1036+
"node_modules/cloud-local-storage/lib/commands/reset-password.js",
1037+
"node_modules/cloud-local-storage/lib/commands/set-item.d.ts",
1038+
"node_modules/cloud-local-storage/lib/commands/set-item.js",
1039+
"node_modules/cloud-local-storage/lib/index.d.ts",
1040+
"node_modules/cloud-local-storage/lib/index.js",
1041+
"node_modules/cloud-local-storage/lib/utils/consts.d.ts",
1042+
"node_modules/cloud-local-storage/lib/utils/consts.js",
1043+
"node_modules/cloud-local-storage/package.json",
1044+
"node_modules/cloud-local-storage/readme.md",
1045+
"node_modules/cloud-local-storage/src/commands/create.ts",
1046+
"node_modules/cloud-local-storage/src/commands/get-all-keys.ts",
1047+
"node_modules/cloud-local-storage/src/commands/get-item.ts",
1048+
"node_modules/cloud-local-storage/src/commands/set-item.ts",
1049+
"node_modules/cloud-local-storage/src/index.ts",
1050+
"node_modules/cloud-local-storage/src/utils/consts.ts",
1051+
"node_modules/cloud-local-storage/tsconfig.json",
10131052
"node_modules/lodash/_apply.js",
10141053
"node_modules/lodash/_arrayAggregator.js",
10151054
"node_modules/lodash/_arrayEach.js",
@@ -2507,7 +2546,7 @@
25072546
"node_modules/@types/aws-lambda/trigger/sqs.d.ts"
25082547
],
25092548
"artifact": "/home/crzy/Desktop/programs/lambdas-aws/api-final/new2/hicetnunc-api/.serverless/hicetnunc-apiv2.zip",
2510-
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1615880662823-2021-03-16T07:44:22.823Z"
2549+
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1616044842570-2021-03-18T05:20:42.570Z"
25112550
},
25122551
"plugins": {
25132552
"$ref": "$[\"service\"][\"plugins\"]"
@@ -2524,7 +2563,7 @@
25242563
"artifact": "/home/crzy/Desktop/programs/lambdas-aws/api-final/new2/hicetnunc-api/.serverless/hicetnunc-apiv2.zip"
25252564
},
25262565
"package": {
2527-
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1615880662823-2021-03-16T07:44:22.823Z",
2566+
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1616044842570-2021-03-18T05:20:42.570Z",
25282567
"artifact": "hicetnunc-apiv2.zip"
25292568
}
25302569
}

conseilUtil.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const getArtisticOutputForAddress = async (address) => {
110110
mintOperationQuery);
111111

112112
const operationGroupIds = mintOperationResult.map(r => r['operation_group_hash'])
113-
const queryChunks = chunkArray(operationGroupIds, 10)
113+
const queryChunks = chunkArray(operationGroupIds, 30)
114114

115115
const makeObjectQuery = (opIds) => {
116116
let mintedObjectsQuery = conseiljs.ConseilQueryBuilder.blankQuery();
@@ -133,7 +133,7 @@ const getArtisticOutputForAddress = async (address) => {
133133
return { key: row['key_hash'], objectId, ipfsHash }
134134
}))))
135135

136-
return objectInfo
136+
return objectInfo.flat(1).sort((a, b) => parseInt(b.objectId) - parseInt(a.objectId))
137137
}
138138

139139
const getArtisticUniverse = async (max_time) => {

index.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ const axios = require('axios')
33
const express = require('express')
44
const cors = require('cors')
55
const _ = require('lodash')
6-
76
const conseilUtil = require('./conseilUtil')
7+
const cls = require('cloud-local-storage')
8+
require('dotenv').config()
89

910
const reducer = (accumulator, currentValue) => accumulator + currentValue;
1011

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

4344
const owners = async (obj) => {
@@ -135,10 +136,13 @@ const ONE_MINUTE_MILLIS = 60 * 1000
135136

136137

137138
const getFeed = async (counter, max_time, res) => {
139+
138140
const now_time = Date.now()
139141
const immutable = (typeof max_time !== 'undefined') && (max_time < now_time)
140142
max_time = (typeof max_time !== 'undefined') ? max_time : customFloor(now_time, ONE_MINUTE_MILLIS)
143+
141144
var arr = await conseilUtil.getArtisticUniverse(max_time)
145+
142146
var feed = offset(desc(arr), counter)
143147
console.log(feed)
144148
feed = await feed.map(async e => {
@@ -160,7 +164,8 @@ const getFeed = async (counter, max_time, res) => {
160164
var aux_arr = results.map(e => e)
161165

162166
res.set('Cache-Control', `public, max-age=${cache_time}`)
163-
//console.log(aux_arr)
167+
168+
console.log(aux_arr)
164169
res.json({ result: aux_arr })
165170
})
166171
}
@@ -180,16 +185,19 @@ const getTzLedger = async (tz, res) => {
180185
console.log(hdao)
181186

182187
var arr = []
183-
184-
var arr = _.union(collection, creations[0])
188+
console.log([...collection, ...creations])
189+
var arr = [...collection, ...creations]
185190

186191
var result = arr.map(async e => {
187192
e.token_info = await getIpfsHash(e.ipfsHash)
193+
188194
if (e.piece != undefined) {
189195
e.token_id = parseInt(e.piece)
190196
} else {
191197
e.token_id = parseInt(e.objectId)
198+
192199
}
200+
console.log(e)
193201
return e
194202
})
195203

@@ -201,7 +209,7 @@ const getTzLedger = async (tz, res) => {
201209
result: _.uniqBy(result, (e) => {
202210
return e.token_id
203211
}),
204-
hdao : hdao
212+
hdao: hdao
205213
})
206214
})
207215

@@ -281,16 +289,26 @@ app.post('/tz', async (req, res) => {
281289
})
282290

283291
app.post('/objkt', async (req, res) => {
284-
res.json({ result: await getObjktById(req.body.objkt_id) })
292+
var list = await axios.get('https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/o.json').then(res => res.data)
293+
294+
list.includes(parseInt(req.body.objkt_id))
295+
?
296+
res.json({ result: [] })
297+
:
298+
res.json({ result: await getObjktById(req.body.objkt_id) })
285299
})
286300

287301
app.post('/hdao', async (req, res) => {
288302
await hDAOFeed(parseInt(req.body.counter), res)
289303
})
290304

291305
app.listen(3001)
292-
module.exports.handler = serverless(app)
306+
//module.exports.handler = serverless(app)
293307

308+
/* const test2 = async () => {
309+
await axios.get('https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/o.json').then(res => console.log(res.data))
310+
}
311+
test2() */
294312
//testTkHolder([{'kt' : 2020}, {'kt' : 2021}])
295313
//getFeed(1)
296314
//getObjktById(2000)

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
"homepage": "https://github.com/hicetnunc2000/hicetnunc#readme",
1919
"dependencies": {
2020
"axios": "^0.21.1",
21+
"cloud-local-storage": "0.0.11",
2122
"conseiljs": "5.0.7-2",
2223
"cors": "^2.8.5",
24+
"dotenv": "^8.2.0",
2325
"express": "^4.17.1",
2426
"fetch": "^1.1.0",
2527
"lodash": "^4.17.21",
2628
"loglevel": "1.7.1",
2729
"node-fetch": "2.6.1",
30+
"serverless-dotenv-plugin": "^3.8.1",
2831
"serverless-http": "^2.7.0"
2932
},
3033
"engines": {

serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package:
99

1010
plugins:
1111
- serverless-plugin-include-dependencies
12-
12+
- serverless-dotenv-plugin
1313
provider:
1414
name: aws
1515
runtime: nodejs12.x

0 commit comments

Comments
 (0)