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

Commit 3cb6ed3

Browse files
author
hicetnunc2000
committed
latest
1 parent ec0e04c commit 3cb6ed3

File tree

5 files changed

+41
-35
lines changed

5 files changed

+41
-35
lines changed

.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/1616132797292-2021-03-19T05:46:37.292Z/hicetnunc-apiv2.zip"
149+
"S3Key": "serverless/hicetnunc-apiv2/dev/1616180496084-2021-03-19T19:01:36.084Z/hicetnunc-apiv2.zip"
150150
},
151151
"FunctionName": "hicetnunc-apiv2-dev-handler",
152152
"Handler": "index.handler",
@@ -170,14 +170,14 @@
170170
"HandlerLogGroup"
171171
]
172172
},
173-
"HandlerLambdaVersionl43NXxTCsqpysRMWyXSvU0lsarIv6k41EVMGBVAAAI": {
173+
"HandlerLambdaVersionxKXiD47XxbV8a0CrQwjITk3MONXyb5JqjEgIyp7EM": {
174174
"Type": "AWS::Lambda::Version",
175175
"DeletionPolicy": "Retain",
176176
"Properties": {
177177
"FunctionName": {
178178
"Ref": "HandlerLambdaFunction"
179179
},
180-
"CodeSha256": "yP30UhwdABdpM1UtDvnZ21GW5zg9jII05figW7uS74k="
180+
"CodeSha256": "nF8jqb9R6Jwn5BvBH8TIt8EhoKsJFfZyPkF8eSd4WH4="
181181
}
182182
},
183183
"ApiGatewayRestApi": {
@@ -389,7 +389,7 @@
389389
"MethodResponses": []
390390
}
391391
},
392-
"ApiGatewayDeployment1616132791720": {
392+
"ApiGatewayDeployment1616180485677": {
393393
"Type": "AWS::ApiGateway::Deployment",
394394
"Properties": {
395395
"RestApiId": {
@@ -451,7 +451,7 @@
451451
"HandlerLambdaFunctionQualifiedArn": {
452452
"Description": "Current Lambda function version",
453453
"Value": {
454-
"Ref": "HandlerLambdaVersionl43NXxTCsqpysRMWyXSvU0lsarIv6k41EVMGBVAAAI"
454+
"Ref": "HandlerLambdaVersionxKXiD47XxbV8a0CrQwjITk3MONXyb5JqjEgIyp7EM"
455455
}
456456
},
457457
"ServiceEndpoint": {

.serverless/hicetnunc-apiv2.zip

93 Bytes
Binary file not shown.

.serverless/serverless-state.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
"S3Bucket": {
164164
"Ref": "ServerlessDeploymentBucket"
165165
},
166-
"S3Key": "serverless/hicetnunc-apiv2/dev/1616132797292-2021-03-19T05:46:37.292Z/hicetnunc-apiv2.zip"
166+
"S3Key": "serverless/hicetnunc-apiv2/dev/1616180496084-2021-03-19T19:01:36.084Z/hicetnunc-apiv2.zip"
167167
},
168168
"FunctionName": "hicetnunc-apiv2-dev-handler",
169169
"Handler": "index.handler",
@@ -187,14 +187,14 @@
187187
"HandlerLogGroup"
188188
]
189189
},
190-
"HandlerLambdaVersionl43NXxTCsqpysRMWyXSvU0lsarIv6k41EVMGBVAAAI": {
190+
"HandlerLambdaVersionxKXiD47XxbV8a0CrQwjITk3MONXyb5JqjEgIyp7EM": {
191191
"Type": "AWS::Lambda::Version",
192192
"DeletionPolicy": "Retain",
193193
"Properties": {
194194
"FunctionName": {
195195
"Ref": "HandlerLambdaFunction"
196196
},
197-
"CodeSha256": "yP30UhwdABdpM1UtDvnZ21GW5zg9jII05figW7uS74k="
197+
"CodeSha256": "nF8jqb9R6Jwn5BvBH8TIt8EhoKsJFfZyPkF8eSd4WH4="
198198
}
199199
},
200200
"ApiGatewayRestApi": {
@@ -406,7 +406,7 @@
406406
"MethodResponses": []
407407
}
408408
},
409-
"ApiGatewayDeployment1616132791720": {
409+
"ApiGatewayDeployment1616180485677": {
410410
"Type": "AWS::ApiGateway::Deployment",
411411
"Properties": {
412412
"RestApiId": {
@@ -468,7 +468,7 @@
468468
"HandlerLambdaFunctionQualifiedArn": {
469469
"Description": "Current Lambda function version",
470470
"Value": {
471-
"Ref": "HandlerLambdaVersionl43NXxTCsqpysRMWyXSvU0lsarIv6k41EVMGBVAAAI"
471+
"Ref": "HandlerLambdaVersionxKXiD47XxbV8a0CrQwjITk3MONXyb5JqjEgIyp7EM"
472472
}
473473
},
474474
"ServiceEndpoint": {
@@ -627,7 +627,7 @@
627627
"memory": 1024,
628628
"runtime": "nodejs12.x",
629629
"vpc": {},
630-
"versionLogicalId": "HandlerLambdaVersionl43NXxTCsqpysRMWyXSvU0lsarIv6k41EVMGBVAAAI"
630+
"versionLogicalId": "HandlerLambdaVersionxKXiD47XxbV8a0CrQwjITk3MONXyb5JqjEgIyp7EM"
631631
}
632632
},
633633
"configValidationMode": "warn",
@@ -2557,7 +2557,7 @@
25572557
"node_modules/@types/aws-lambda/trigger/sqs.d.ts"
25582558
],
25592559
"artifact": "/home/crzy/Desktop/programs/lambdas-aws/api-final/new2/hicetnunc-api/.serverless/hicetnunc-apiv2.zip",
2560-
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1616132797292-2021-03-19T05:46:37.292Z"
2560+
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1616180496084-2021-03-19T19:01:36.084Z"
25612561
},
25622562
"plugins": {
25632563
"$ref": "$[\"service\"][\"plugins\"]"
@@ -2574,7 +2574,7 @@
25742574
"artifact": "/home/crzy/Desktop/programs/lambdas-aws/api-final/new2/hicetnunc-api/.serverless/hicetnunc-apiv2.zip"
25752575
},
25762576
"package": {
2577-
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1616132797292-2021-03-19T05:46:37.292Z",
2577+
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1616180496084-2021-03-19T19:01:36.084Z",
25782578
"artifact": "hicetnunc-apiv2.zip"
25792579
}
25802580
}

conseilUtil.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ const getArtisticUniverse = async (max_time) => {
141141
mintOperationQuery = conseiljs.ConseilQueryBuilder.addFields(mintOperationQuery, 'operation_group_hash');
142142
mintOperationQuery = conseiljs.ConseilQueryBuilder.addPredicate(mintOperationQuery, 'kind', conseiljs.ConseilOperator.EQ, ['transaction'])
143143
mintOperationQuery = conseiljs.ConseilQueryBuilder.addPredicate(mintOperationQuery, 'timestamp', conseiljs.ConseilOperator.AFTER, [1612240919000]) // 2021 Feb 1
144-
mintOperationQuery = conseiljs.ConseilQueryBuilder.addPredicate(mintOperationQuery, 'timestamp', conseiljs.ConseilOperator.BEFORE, [max_time]) // quantized time (1min)
145144
mintOperationQuery = conseiljs.ConseilQueryBuilder.addPredicate(mintOperationQuery, 'status', conseiljs.ConseilOperator.EQ, ['applied'])
146145
mintOperationQuery = conseiljs.ConseilQueryBuilder.addPredicate(mintOperationQuery, 'destination', conseiljs.ConseilOperator.EQ, [mainnet.protocol])
147146
mintOperationQuery = conseiljs.ConseilQueryBuilder.addPredicate(mintOperationQuery, 'parameters_entrypoints', conseiljs.ConseilOperator.EQ, ['mint_OBJKT'])
@@ -205,14 +204,21 @@ const getArtisticUniverse = async (max_time) => {
205204
const objectQueries = queryChunks.map(c => makeObjectQuery(c))
206205

207206
let universe = []
208-
await Promise.all(objectQueries.map(async (q) => await conseiljs.TezosConseilClient.getTezosEntityData({ url: conseilServer, apiKey: conseilApiKey, network: 'mainnet' }, 'mainnet', 'big_map_contents', q)
209-
.then(result => result.map(row => {
210-
const objectId = row['value'].toString().replace(/^Pair ([0-9]{1,}) .*/, '$1')
211-
const objectUrl = row['value'].toString().replace(/.* 0x([0-9a-z]{1,}) \}$/, '$1')
212-
const ipfsHash = Buffer.from(objectUrl, 'hex').toString().slice(7);
213-
214-
universe.push({ objectId, ipfsHash, minter: artistMap[objectId], swaps: swapMap[objectId] !== undefined ? swapMap[objectId] : []})
215-
}))))
207+
await Promise.all(
208+
objectQueries.map(async (q) => {
209+
const r = []
210+
try {
211+
r = await conseiljs.TezosConseilClient.getTezosEntityData({ url: conseilServer, apiKey: conseilApiKey, network: 'mainnet' }, 'mainnet', 'big_map_contents', q)
212+
.then(result => result.map(row => {
213+
const objectId = row['value'].toString().replace(/^Pair ([0-9]{1,}) .*/, '$1')
214+
const objectUrl = row['value'].toString().replace(/.* 0x([0-9a-z]{1,}) \}$/, '$1')
215+
const ipfsHash = Buffer.from(objectUrl, 'hex').toString().slice(7);
216+
217+
universe.push({ objectId, ipfsHash, minter: artistMap[objectId], swaps: swapMap[objectId] !== undefined ? swapMap[objectId] : []})
218+
})) // NOTE: it's a work in progress, this will drop failed requests and return a smaller set than expected
219+
} finally {
220+
return r
221+
}}))
216222

217223
return universe
218224
}

index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ const customFloor = function (value, roundTo) {
135135
const ONE_MINUTE_MILLIS = 60 * 1000
136136

137137

138-
const getFeed = async (counter, max_time, res) => {
138+
const getFeed = async (counter, res) => {
139139

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

146146
var feed = offset(desc(arr), counter)
147147
console.log(feed)
@@ -152,18 +152,18 @@ const getFeed = async (counter, max_time, res) => {
152152
return e
153153
})
154154
//console.log(feed)
155-
var cache_time
155+
/* var cache_time
156156
if (immutable) {
157157
cache_time = 60 * 10
158158
}
159159
else {
160160
cache_time = (int)(((max_time + ONE_MINUTE_MILLIS) - now_time) / 1000)
161-
}
161+
} */
162162
var promise = Promise.all(feed.map(e => e))
163163
promise.then(async (results) => {
164164
var aux_arr = results.map(e => e)
165165

166-
res.set('Cache-Control', `public, max-age=${cache_time}`)
166+
//res.set('Cache-Control', `public, max-age=${cache_time}`)
167167

168168
console.log(aux_arr)
169169
res.json({ result: aux_arr })
@@ -272,14 +272,14 @@ const app = express()
272272
app.use(express.json())
273273
app.use(cors({ origin: '*' }))
274274

275-
app.get('/feed', async (req, res) => {
276-
var counter = req.query.counter
275+
app.post('/feed', async (req, res) => {
276+
/* var counter = req.query.counter
277277
var max_time = req.query.hasOwnProperty('time') ? customFloor(req.query.time, ONE_MINUTE_MILLIS) : null
278278
const now_time_qt = customFloor(Date.now(), ONE_MINUTE_MILLIS)
279279
if (max_time != null & max_time > now_time_qt) {
280280
max_time = null
281-
}
282-
await getFeed(counter, max_time, res)
281+
} */
282+
await getFeed(req.body.counter, res)
283283
})
284284

285285
app.post('/tz', async (req, res) => {
@@ -308,8 +308,8 @@ app.post('/hdao', async (req, res) => {
308308
await hDAOFeed(parseInt(req.body.counter), res)
309309
})
310310

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

314314
/* const test2 = async () => {
315315
await axios.get('https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/o.json').then(res => console.log(res.data))

0 commit comments

Comments
 (0)