@dcl/content-validator 4.2.4-20230123164620.commit-1ba0cf1 → 4.2.4-20230125194827.commit-f90482b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenes.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/scenes.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,UAAU,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"scenes.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/scenes.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,UAAU,EAAE,MAAM,aAAa,CAAA;AAEpD;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,UAuDpB,CAAA"}
|
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.scenes = void 0;
|
|
7
|
-
const ms_1 = __importDefault(require("ms"));
|
|
8
4
|
const types_1 = require("../../types");
|
|
9
|
-
const SCENE_LOOKBACK_TIME = (0, ms_1.default)('5m');
|
|
10
5
|
/**
|
|
11
6
|
* Checks if the given address has access to the given parcel at the given timestamp.
|
|
12
7
|
* @public
|
|
13
8
|
*/
|
|
14
9
|
exports.scenes = {
|
|
15
|
-
validate: async ({ externalCalls, subGraphs, logs }, deployment) => {
|
|
10
|
+
validate: async ({ externalCalls, theGraphClient, subGraphs, logs }, deployment) => {
|
|
16
11
|
const { entity } = deployment;
|
|
17
12
|
const { pointers, timestamp } = entity;
|
|
18
13
|
const logger = logs.getLogger('scenes-validator');
|
|
19
|
-
let block;
|
|
20
|
-
try {
|
|
21
|
-
// Check that the address has access (we check both the present and the 5 min into the past to avoid synchronization issues in the blockchain)
|
|
22
|
-
const blockInfo = await subGraphs.l1BlockSearch.findBlockForTimestamp(timestamp - SCENE_LOOKBACK_TIME);
|
|
23
|
-
if (blockInfo === undefined) {
|
|
24
|
-
return (0, types_1.fromErrors)('Deployment timestamp is invalid, no matching block found');
|
|
25
|
-
}
|
|
26
|
-
block = blockInfo.block;
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
return (0, types_1.fromErrors)(`Deployment timestamp is invalid, no matching block found: ${err}`);
|
|
30
|
-
}
|
|
31
14
|
const ethAddress = externalCalls.ownerAddress(deployment.auditInfo);
|
|
32
15
|
const errors = [];
|
|
33
16
|
const lowerCasePointers = pointers.map((pointer) => pointer.toLowerCase());
|
|
@@ -43,11 +26,17 @@ exports.scenes = {
|
|
|
43
26
|
errors.push(`Scene pointers should only contain two integers separated by a comma, for example (10,10) or (120,-45). Invalid pointer: ${pointer}`);
|
|
44
27
|
}
|
|
45
28
|
}
|
|
29
|
+
const { blockAtDeployment, blockFiveMinBeforeDeployment } = await theGraphClient.findBlocksForTimestamp(timestamp, subGraphs.l1BlockSearch);
|
|
46
30
|
try {
|
|
47
|
-
const
|
|
31
|
+
const accessAtBlock = blockAtDeployment
|
|
32
|
+
? await subGraphs.L1.checker.checkLAND(ethAddress, batch, blockAtDeployment)
|
|
33
|
+
: batch.map(() => false);
|
|
34
|
+
const accessAtFiveMinBeforeBlock = blockFiveMinBeforeDeployment
|
|
35
|
+
? await subGraphs.L1.checker.checkLAND(ethAddress, batch, blockFiveMinBeforeDeployment)
|
|
36
|
+
: batch.map(() => false);
|
|
48
37
|
for (let i = 0; i < batch.length; i++) {
|
|
49
38
|
const [x, y] = batch[i];
|
|
50
|
-
const hasAccess =
|
|
39
|
+
const hasAccess = accessAtBlock[i] || accessAtFiveMinBeforeBlock[i];
|
|
51
40
|
if (!hasAccess) {
|
|
52
41
|
errors.push(`The provided Eth Address does not have access to the following parcel: (${x},${y})`);
|
|
53
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenes.js","sourceRoot":"","sources":["../../../src/validations/access-checker/scenes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scenes.js","sourceRoot":"","sources":["../../../src/validations/access-checker/scenes.ts"],"names":[],"mappings":";;;AACA,uCAAoD;AAEpD;;;GAGG;AACU,QAAA,MAAM,GAAe;IAChC,QAAQ,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE;QACjF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;QAC7B,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,CAAA;QAEtC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAA;QAEjD,MAAM,UAAU,GAAG,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;QAEnE,MAAM,MAAM,GAAG,EAAE,CAAA;QACjB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;QAE1E,MAAM,KAAK,GAAuB,EAAE,CAAA;QAEpC,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE;YACvC,MAAM,YAAY,GAAa,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACjD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC7B,MAAM,CAAC,GAAW,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;gBAC/C,MAAM,CAAC,GAAW,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;gBAE/C,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;aACnB;iBAAM;gBACL,MAAM,CAA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F,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/content-validator",
|
|
3
|
-
"version": "4.2.4-
|
|
3
|
+
"version": "4.2.4-20230125194827.commit-f90482b",
|
|
4
4
|
"description": "Catalyst content validations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"files": [
|
|
67
67
|
"dist"
|
|
68
68
|
],
|
|
69
|
-
"commit": "
|
|
69
|
+
"commit": "f90482b7ef05ed2a0862ac26625353cb06cc829f"
|
|
70
70
|
}
|