@dcl/content-validator 4.2.4-20230125194827.commit-f90482b → 4.2.4-4135566596.commit-6ae9fb8
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/the-graph-client/the-graph-client.d.ts +1 -5
- package/dist/the-graph-client/the-graph-client.d.ts.map +1 -1
- package/dist/the-graph-client/the-graph-client.js +83 -49
- package/dist/the-graph-client/the-graph-client.js.map +1 -1
- package/dist/types.d.ts +22 -45
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validations/ADR45.d.ts +2 -2
- package/dist/validations/ADR45.d.ts.map +1 -1
- package/dist/validations/ADR45.js +7 -8
- package/dist/validations/ADR45.js.map +1 -1
- package/dist/validations/ADR51.d.ts +1 -1
- package/dist/validations/ADR51.d.ts.map +1 -1
- package/dist/validations/access-checker/access.d.ts +2 -2
- package/dist/validations/access-checker/access.d.ts.map +1 -1
- package/dist/validations/access-checker/access.js +15 -17
- package/dist/validations/access-checker/access.js.map +1 -1
- package/dist/validations/access-checker/emotes.d.ts +2 -2
- package/dist/validations/access-checker/emotes.d.ts.map +1 -1
- package/dist/validations/access-checker/emotes.js +7 -8
- package/dist/validations/access-checker/emotes.js.map +1 -1
- package/dist/validations/access-checker/items/collection-asset.d.ts +2 -2
- package/dist/validations/access-checker/items/collection-asset.d.ts.map +1 -1
- package/dist/validations/access-checker/items/collection-asset.js +106 -43
- package/dist/validations/access-checker/items/collection-asset.js.map +1 -1
- package/dist/validations/access-checker/items/items.d.ts +4 -6
- package/dist/validations/access-checker/items/items.d.ts.map +1 -1
- package/dist/validations/access-checker/items/items.js +23 -24
- package/dist/validations/access-checker/items/items.js.map +1 -1
- package/dist/validations/access-checker/items/third-party-asset.d.ts.map +1 -1
- package/dist/validations/access-checker/items/third-party-asset.js +80 -21
- package/dist/validations/access-checker/items/third-party-asset.js.map +1 -1
- package/dist/validations/access-checker/profiles.d.ts +6 -6
- package/dist/validations/access-checker/profiles.d.ts.map +1 -1
- package/dist/validations/access-checker/profiles.js +59 -61
- package/dist/validations/access-checker/profiles.js.map +1 -1
- package/dist/validations/access-checker/scenes.d.ts +2 -2
- package/dist/validations/access-checker/scenes.d.ts.map +1 -1
- package/dist/validations/access-checker/scenes.js +243 -34
- package/dist/validations/access-checker/scenes.js.map +1 -1
- package/dist/validations/access-checker/stores.d.ts +2 -2
- package/dist/validations/access-checker/stores.d.ts.map +1 -1
- package/dist/validations/access-checker/stores.js +14 -15
- package/dist/validations/access-checker/stores.js.map +1 -1
- package/dist/validations/access-checker/wearables.d.ts +2 -2
- package/dist/validations/access-checker/wearables.d.ts.map +1 -1
- package/dist/validations/access-checker/wearables.js +9 -10
- package/dist/validations/access-checker/wearables.js.map +1 -1
- package/dist/validations/content.d.ts +6 -6
- package/dist/validations/content.d.ts.map +1 -1
- package/dist/validations/content.js +44 -50
- package/dist/validations/content.js.map +1 -1
- package/dist/validations/entity-structure.d.ts +2 -2
- package/dist/validations/entity-structure.d.ts.map +1 -1
- package/dist/validations/entity-structure.js +10 -11
- package/dist/validations/entity-structure.js.map +1 -1
- package/dist/validations/index.d.ts +9 -4
- package/dist/validations/index.d.ts.map +1 -1
- package/dist/validations/index.js +7 -7
- package/dist/validations/index.js.map +1 -1
- package/dist/validations/ipfs-hashing.d.ts +2 -2
- package/dist/validations/ipfs-hashing.d.ts.map +1 -1
- package/dist/validations/ipfs-hashing.js +8 -10
- package/dist/validations/ipfs-hashing.js.map +1 -1
- package/dist/validations/items/emotes.d.ts +4 -4
- package/dist/validations/items/emotes.d.ts.map +1 -1
- package/dist/validations/items/emotes.js +22 -24
- package/dist/validations/items/emotes.js.map +1 -1
- package/dist/validations/items/items.d.ts +4 -4
- package/dist/validations/items/items.d.ts.map +1 -1
- package/dist/validations/items/items.js +54 -55
- package/dist/validations/items/items.js.map +1 -1
- package/dist/validations/items/wearables.d.ts +4 -3
- package/dist/validations/items/wearables.d.ts.map +1 -1
- package/dist/validations/items/wearables.js +16 -17
- package/dist/validations/items/wearables.js.map +1 -1
- package/dist/validations/metadata-schema.d.ts +2 -2
- package/dist/validations/metadata-schema.d.ts.map +1 -1
- package/dist/validations/metadata-schema.js +17 -21
- package/dist/validations/metadata-schema.js.map +1 -1
- package/dist/validations/profile.d.ts +6 -6
- package/dist/validations/profile.d.ts.map +1 -1
- package/dist/validations/profile.js +55 -63
- package/dist/validations/profile.js.map +1 -1
- package/dist/validations/scene.d.ts +3 -3
- package/dist/validations/scene.d.ts.map +1 -1
- package/dist/validations/scene.js +5 -7
- package/dist/validations/scene.js.map +1 -1
- package/dist/validations/signature.d.ts +2 -2
- package/dist/validations/signature.d.ts.map +1 -1
- package/dist/validations/signature.js +6 -8
- package/dist/validations/signature.js.map +1 -1
- package/dist/validations/size.d.ts +2 -2
- package/dist/validations/size.d.ts.map +1 -1
- package/dist/validations/size.js +28 -29
- package/dist/validations/size.js.map +1 -1
- package/dist/validations/validations.d.ts +9 -9
- package/dist/validations/validations.d.ts.map +1 -1
- package/dist/validations/validations.js +34 -38
- package/dist/validations/validations.js.map +1 -1
- package/package.json +5 -10
- package/dist/content-validator.api.json +0 -1669
- package/dist/tsdoc-metadata.json +0 -11
|
@@ -7,42 +7,41 @@ const types_1 = require("../../types");
|
|
|
7
7
|
const profile_1 = require("../profile");
|
|
8
8
|
const timestamps_1 = require("../timestamps");
|
|
9
9
|
const validations_1 = require("../validations");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (0, types_1.validationFailed)(`The given pointer is not a valid ethereum address.`);
|
|
23
|
-
}
|
|
24
|
-
else if (pointer !== ethAddress.toLowerCase()) {
|
|
25
|
-
return (0, types_1.validationFailed)(`You can only alter your own profile. The pointer address and the signer address are different (pointer:${pointer} signer: ${ethAddress.toLowerCase()}).`);
|
|
26
|
-
}
|
|
27
|
-
return types_1.OK;
|
|
10
|
+
async function pointerIsValid(components, deployment) {
|
|
11
|
+
const pointers = deployment.entity.pointers;
|
|
12
|
+
const ethAddress = components.externalCalls.ownerAddress(deployment.auditInfo);
|
|
13
|
+
if (pointers.length !== 1)
|
|
14
|
+
return (0, types_1.validationFailed)(`Only one pointer is allowed when you create a Profile. Received: ${pointers}`);
|
|
15
|
+
const pointer = pointers[0].toLowerCase();
|
|
16
|
+
if (pointer.startsWith('default')) {
|
|
17
|
+
if (!components.externalCalls.isAddressOwnedByDecentraland(ethAddress))
|
|
18
|
+
return (0, types_1.validationFailed)(`Only Decentraland can add or modify default profiles`);
|
|
19
|
+
}
|
|
20
|
+
else if (!schemas_1.EthAddress.validate(pointer)) {
|
|
21
|
+
return (0, types_1.validationFailed)(`The given pointer is not a valid ethereum address.`);
|
|
28
22
|
}
|
|
29
|
-
|
|
23
|
+
else if (pointer !== ethAddress.toLowerCase()) {
|
|
24
|
+
return (0, types_1.validationFailed)(`You can only alter your own profile. The pointer address and the signer address are different (pointer:${pointer} signer: ${ethAddress.toLowerCase()}).`);
|
|
25
|
+
}
|
|
26
|
+
return types_1.OK;
|
|
27
|
+
}
|
|
28
|
+
exports.pointerIsValid = pointerIsValid;
|
|
30
29
|
function allClaimedNames(entity) {
|
|
31
30
|
return entity.metadata.avatars
|
|
32
31
|
.filter((avatar) => avatar.hasClaimedName)
|
|
33
32
|
.map((avatar) => avatar.name)
|
|
34
33
|
.filter((name) => name && name.trim().length > 0);
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
async function ownsNames(components, deployment) {
|
|
36
|
+
const { externalCalls, theGraphClient } = components;
|
|
37
|
+
const ethAddress = externalCalls.ownerAddress(deployment.auditInfo);
|
|
38
|
+
const names = allClaimedNames(deployment.entity);
|
|
39
|
+
const namesCheckResult = await theGraphClient.ownsNamesAtTimestamp(ethAddress, names, deployment.entity.timestamp);
|
|
40
|
+
if (!namesCheckResult.result)
|
|
41
|
+
return (0, types_1.validationFailed)(`The following names (${namesCheckResult.failing?.join(', ')}) are not owned by the address ${ethAddress.toLowerCase()}).`);
|
|
42
|
+
return types_1.OK;
|
|
43
|
+
}
|
|
44
|
+
exports.ownsNames = ownsNames;
|
|
46
45
|
function isBaseAvatar(urn) {
|
|
47
46
|
return urn.includes('base-avatars');
|
|
48
47
|
}
|
|
@@ -77,41 +76,40 @@ async function allEmoteUrns(entity) {
|
|
|
77
76
|
}
|
|
78
77
|
return (await Promise.all(allEmotesInProfilePromises)).filter((wearableId) => !!wearableId);
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (depoymentTimestamp >= timestamps_1.ADR_74_TIMESTAMP) {
|
|
91
|
-
for (const urn of await allEmoteUrns(deployment.entity)) {
|
|
92
|
-
itemUrns.push(urn);
|
|
93
|
-
}
|
|
79
|
+
async function ownsItems(components, deployment) {
|
|
80
|
+
const { externalCalls, theGraphClient } = components;
|
|
81
|
+
const ethAddress = externalCalls.ownerAddress(deployment.auditInfo);
|
|
82
|
+
const depoymentTimestamp = deployment.entity.timestamp;
|
|
83
|
+
const itemUrns = [];
|
|
84
|
+
if (depoymentTimestamp >= timestamps_1.ADR_75_TIMESTAMP) {
|
|
85
|
+
for (const urn of await allOnChainWearableUrns(deployment.entity)) {
|
|
86
|
+
itemUrns.push(urn);
|
|
94
87
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
}
|
|
89
|
+
if (depoymentTimestamp >= timestamps_1.ADR_74_TIMESTAMP) {
|
|
90
|
+
for (const urn of await allEmoteUrns(deployment.entity)) {
|
|
91
|
+
itemUrns.push(urn);
|
|
98
92
|
}
|
|
99
|
-
return types_1.OK;
|
|
100
93
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
94
|
+
const itemsOwnershipResult = await theGraphClient.ownsItemsAtTimestamp(ethAddress, itemUrns, deployment.entity.timestamp);
|
|
95
|
+
if (!itemsOwnershipResult.result) {
|
|
96
|
+
return (0, types_1.validationFailed)(`The following items (${itemsOwnershipResult.failing?.join(', ')}) are not owned by the address ${ethAddress.toLowerCase()}).`);
|
|
97
|
+
}
|
|
98
|
+
return types_1.OK;
|
|
99
|
+
}
|
|
100
|
+
exports.ownsItems = ownsItems;
|
|
101
|
+
async function profileSlotsAreNotRepeated(components, deployment) {
|
|
102
|
+
const allAvatars = deployment.entity.metadata?.avatars ?? [];
|
|
103
|
+
const allEmotes = allAvatars.flatMap((avatar) => avatar.avatar.emotes ?? []);
|
|
104
|
+
const usedSlots = new Set();
|
|
105
|
+
for (const { slot } of allEmotes) {
|
|
106
|
+
if (usedSlots.has(slot)) {
|
|
107
|
+
return (0, types_1.validationFailed)('Emote slots should not be repeated.');
|
|
112
108
|
}
|
|
113
|
-
|
|
109
|
+
usedSlots.add(slot);
|
|
114
110
|
}
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
return types_1.OK;
|
|
112
|
+
}
|
|
113
|
+
exports.profileSlotsAreNotRepeated = profileSlotsAreNotRepeated;
|
|
114
|
+
exports.profiles = (0, validations_1.validateAll)(pointerIsValid, ownsNames, ownsItems, profileSlotsAreNotRepeated);
|
|
117
115
|
//# sourceMappingURL=profiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/validations/access-checker/profiles.ts"],"names":[],"mappings":";;;AAAA,0CAAyD;AACzD,oDAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/validations/access-checker/profiles.ts"],"names":[],"mappings":";;;AAAA,0CAAyD;AACzD,oDAA4C;AAC5C,uCAAgH;AAChH,wCAAuC;AACvC,8CAAkE;AAClE,gDAA4C;AAErC,KAAK,UAAU,cAAc,CAClC,UAA6D,EAC7D,UAAgC;IAEhC,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAA;IAC3C,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IAE9E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QACvB,OAAO,IAAA,wBAAgB,EAAC,oEAAoE,QAAQ,EAAE,CAAC,CAAA;IAEzG,MAAM,OAAO,GAAW,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAEjD,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QACjC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,4BAA4B,CAAC,UAAU,CAAC;YACpE,OAAO,IAAA,wBAAgB,EAAC,sDAAsD,CAAC,CAAA;KAClF;SAAM,IAAI,CAAC,oBAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACxC,OAAO,IAAA,wBAAgB,EAAC,oDAAoD,CAAC,CAAA;KAC9E;SAAM,IAAI,OAAO,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE;QAC/C,OAAO,IAAA,wBAAgB,EACrB,0GAA0G,OAAO,YAAY,UAAU,CAAC,WAAW,EAAE,IAAI,CAC1J,CAAA;KACF;IACD,OAAO,UAAE,CAAA;AACX,CAAC;AAvBD,wCAuBC;AAED,SAAS,eAAe,CAAC,MAAc;IACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO;SAC3B,MAAM,CAAC,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AM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAA;IAC3B,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS,EAAE;QAChC,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACvB,OAAO,IAAA,wBAAgB,EAAC,qCAAqC,CAAC,CAAA;SAC/D;QACD,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;KACpB;IACD,OAAO,UAAE,CAAA;AACX,CAAC;AAdD,gEAcC;AAEY,QAAA,QAAQ,GAAe,IAAA,yBAAW,EAAC,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,0BAA0B,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentValidatorComponents, DeploymentToValidate } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Checks if the given address has access to the given parcel at the given timestamp.
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare function scenes(components: Pick<ContentValidatorComponents, 'externalCalls' | 'logs' | 'subGraphs'>, deployment: DeploymentToValidate): Promise<import("../../types").ValidationResponse>;
|
|
7
7
|
//# sourceMappingURL=scenes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenes.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/scenes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scenes.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/scenes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAA6B,MAAM,aAAa,CAAA;AAgCzG;;;GAGG;AACH,wBAAsB,MAAM,CAC1B,UAAU,EAAE,IAAI,CAAC,0BAA0B,EAAE,eAAe,GAAG,MAAM,GAAG,WAAW,CAAC,EACpF,UAAU,EAAE,oBAAoB,qDAsSjC"}
|
|
@@ -1,52 +1,261 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.scenes = void 0;
|
|
7
|
+
const ms_1 = __importDefault(require("ms"));
|
|
4
8
|
const types_1 = require("../../types");
|
|
5
9
|
/**
|
|
6
10
|
* Checks if the given address has access to the given parcel at the given timestamp.
|
|
7
11
|
* @public
|
|
8
12
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
async function scenes(components, deployment) {
|
|
14
|
+
const { externalCalls, subGraphs, logs } = components;
|
|
15
|
+
const logger = logs.getLogger('scenes access validator');
|
|
16
|
+
const getAuthorizations = async (owner, operator, timestamp) => {
|
|
17
|
+
const query = `
|
|
18
|
+
query GetAuthorizations($owner: String!, $operator: String!, $timestamp: Int!) {
|
|
19
|
+
authorizations(
|
|
20
|
+
where: {
|
|
21
|
+
owner: $owner,
|
|
22
|
+
operator: $operator,
|
|
23
|
+
createdAt_lte: $timestamp
|
|
24
|
+
},
|
|
25
|
+
orderBy: timestamp,
|
|
26
|
+
orderDirection: desc
|
|
27
|
+
) {
|
|
28
|
+
type
|
|
29
|
+
isApproved
|
|
30
|
+
}
|
|
31
|
+
}`;
|
|
32
|
+
const variables = {
|
|
33
|
+
owner,
|
|
34
|
+
operator,
|
|
35
|
+
timestamp: Math.floor(timestamp / 1000) // js(ms) -> UNIX(s)
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
return (await subGraphs.L1.landManager.query(query, variables)).authorizations;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
logger.error(`Error fetching authorizations for ${owner}`);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const getEstate = async (estateId, timestamp) => {
|
|
46
|
+
/**
|
|
47
|
+
* You can use `owner`, `operator` and `updateOperator` to check the current value for that estate.
|
|
48
|
+
* Keep in mind that each association (owners, operators, etc) is capped to a thousand (1000) results.
|
|
49
|
+
* For more information, you can use the query explorer at https://thegraph.com/explorer/subgraph/decentraland/land-manager
|
|
50
|
+
*/
|
|
51
|
+
const query = `
|
|
52
|
+
query GetEstate($estateId: String!, $timestamp: Int!) {
|
|
53
|
+
estates(where:{ id: $estateId }) {
|
|
54
|
+
id
|
|
55
|
+
owners(
|
|
56
|
+
where: { createdAt_lte: $timestamp },
|
|
57
|
+
orderBy: timestamp,
|
|
58
|
+
orderDirection: desc,
|
|
59
|
+
first: 1
|
|
60
|
+
) {
|
|
61
|
+
address
|
|
62
|
+
}
|
|
63
|
+
operators(
|
|
64
|
+
where: { createdAt_lte: $timestamp },
|
|
65
|
+
orderBy: timestamp,
|
|
66
|
+
orderDirection: desc,
|
|
67
|
+
first: 1
|
|
68
|
+
) {
|
|
69
|
+
address
|
|
70
|
+
}
|
|
71
|
+
updateOperators(
|
|
72
|
+
where: { createdAt_lte: $timestamp },
|
|
73
|
+
orderBy: timestamp,
|
|
74
|
+
orderDirection: desc,
|
|
75
|
+
first: 1
|
|
76
|
+
) {
|
|
77
|
+
address
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}`;
|
|
81
|
+
const variables = {
|
|
82
|
+
estateId,
|
|
83
|
+
timestamp: Math.floor(timestamp / 1000) // UNIX
|
|
84
|
+
};
|
|
85
|
+
try {
|
|
86
|
+
return (await subGraphs.L1.landManager.query(query, variables)).estates[0];
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
logger.error(`Error fetching estate (${estateId})`);
|
|
90
|
+
throw error;
|
|
28
91
|
}
|
|
29
|
-
|
|
92
|
+
};
|
|
93
|
+
const getParcel = async (x, y, timestamp) => {
|
|
94
|
+
/**
|
|
95
|
+
* You can use `owner`, `operator` and `updateOperator` to check the current value for that parcel.
|
|
96
|
+
* Keep in mind that each association (owners, operators, etc) is capped to a thousand (1000) results.
|
|
97
|
+
* For more information, you can use the query explorer at https://thegraph.com/explorer/subgraph/decentraland/land-manager
|
|
98
|
+
*/
|
|
99
|
+
const query = `
|
|
100
|
+
query GetParcel($x: Int!, $y: Int!, $timestamp: Int!) {
|
|
101
|
+
parcels(where:{ x: $x, y: $y }) {
|
|
102
|
+
estates(
|
|
103
|
+
where: { createdAt_lte: $timestamp },
|
|
104
|
+
orderBy: createdAt,
|
|
105
|
+
orderDirection: desc,
|
|
106
|
+
first: 1
|
|
107
|
+
) {
|
|
108
|
+
estateId
|
|
109
|
+
}
|
|
110
|
+
owners(
|
|
111
|
+
where: { createdAt_lte: $timestamp },
|
|
112
|
+
orderBy: timestamp,
|
|
113
|
+
orderDirection: desc,
|
|
114
|
+
first: 1
|
|
115
|
+
) {
|
|
116
|
+
address
|
|
117
|
+
}
|
|
118
|
+
operators(
|
|
119
|
+
where: { createdAt_lte: $timestamp },
|
|
120
|
+
orderBy: timestamp,
|
|
121
|
+
orderDirection: desc,
|
|
122
|
+
first: 1
|
|
123
|
+
) {
|
|
124
|
+
address
|
|
125
|
+
}
|
|
126
|
+
updateOperators(
|
|
127
|
+
where: { createdAt_lte: $timestamp },
|
|
128
|
+
orderBy: timestamp,
|
|
129
|
+
orderDirection: desc,
|
|
130
|
+
first: 1
|
|
131
|
+
) {
|
|
132
|
+
address
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}`;
|
|
136
|
+
const variables = {
|
|
137
|
+
x,
|
|
138
|
+
y,
|
|
139
|
+
timestamp: Math.floor(timestamp / 1000) // UNIX
|
|
140
|
+
};
|
|
30
141
|
try {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
142
|
+
const r = await subGraphs.L1.landManager.query(query, variables);
|
|
143
|
+
if (r.parcels && r.parcels.length)
|
|
144
|
+
return r.parcels[0];
|
|
145
|
+
logger.error(`Error fetching parcel (${x}, ${y}, ${timestamp}): ${JSON.stringify(r)}`);
|
|
146
|
+
throw new Error(`Error fetching parcel (${x}, ${y}), ${timestamp}`);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
logger.error(`Error fetching parcel (${x}, ${y}, ${timestamp})`);
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const hasAccessThroughAuthorizations = async (owner, ethAddress, timestamp) => {
|
|
154
|
+
/* You also get access if you received:
|
|
155
|
+
* - an authorization with isApproved and type Operator, ApprovalForAll or UpdateManager
|
|
156
|
+
* at that time
|
|
157
|
+
*/
|
|
158
|
+
const authorizations = await getAuthorizations(owner.toLowerCase(), ethAddress.toLowerCase(), timestamp);
|
|
159
|
+
const firstOperatorAuthorization = authorizations.find((authorization) => authorization.type === 'Operator');
|
|
160
|
+
const firstApprovalForAllAuthorization = authorizations.find((authorization) => authorization.type === 'ApprovalForAll');
|
|
161
|
+
const firstUpdateManagerAuthorization = authorizations.find((authorization) => authorization.type === 'UpdateManager');
|
|
162
|
+
if (firstOperatorAuthorization?.isApproved ||
|
|
163
|
+
firstApprovalForAllAuthorization?.isApproved ||
|
|
164
|
+
firstUpdateManagerAuthorization?.isApproved) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
};
|
|
169
|
+
const hasAccessThroughFirstLevelAuthorities = async (target, ethAddress) => {
|
|
170
|
+
const firstLevelAuthorities = [...target.owners, ...target.operators, ...target.updateOperators]
|
|
171
|
+
.filter((addressSnapshot) => addressSnapshot.address)
|
|
172
|
+
.map((addressSnapshot) => addressSnapshot.address.toLowerCase());
|
|
173
|
+
return firstLevelAuthorities.includes(ethAddress.toLowerCase());
|
|
174
|
+
};
|
|
175
|
+
const isEstateUpdateAuthorized = async (estateId, timestamp, ethAddress) => {
|
|
176
|
+
const estate = await getEstate(estateId.toString(), timestamp);
|
|
177
|
+
if (estate) {
|
|
178
|
+
return ((await hasAccessThroughFirstLevelAuthorities(estate, ethAddress)) ||
|
|
179
|
+
(await hasAccessThroughAuthorizations(estate.owners[0].address, ethAddress, timestamp)));
|
|
180
|
+
}
|
|
181
|
+
throw new Error(`Couldn\'t find the state ${estateId}`);
|
|
182
|
+
};
|
|
183
|
+
const isParcelUpdateAuthorized = async (x, y, timestamp, ethAddress, _externalCalls) => {
|
|
184
|
+
/* You get direct access if you were the:
|
|
185
|
+
* - owner
|
|
186
|
+
* - operator
|
|
187
|
+
* - update operator
|
|
188
|
+
* at that time
|
|
189
|
+
*/
|
|
190
|
+
const parcel = await getParcel(x, y, timestamp);
|
|
191
|
+
if (parcel) {
|
|
192
|
+
const belongsToEstate = parcel.estates != undefined && parcel.estates.length > 0 && parcel.estates[0].estateId != undefined;
|
|
193
|
+
return ((await hasAccessThroughFirstLevelAuthorities(parcel, ethAddress)) ||
|
|
194
|
+
(await hasAccessThroughAuthorizations(parcel.owners[0].address, ethAddress, timestamp)) ||
|
|
195
|
+
(belongsToEstate && (await isEstateUpdateAuthorized(parcel.estates[0].estateId, timestamp, ethAddress))));
|
|
196
|
+
}
|
|
197
|
+
throw new Error(`Parcel(${x},${y},${timestamp}) not found`);
|
|
198
|
+
};
|
|
199
|
+
const checkParcelAccess = async (x, y, timestamp, ethAddress, externalCalls) => {
|
|
200
|
+
try {
|
|
201
|
+
return await retry(() => isParcelUpdateAuthorized(x, y, timestamp, ethAddress, externalCalls), 5, '0.1s');
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
logger.error(`Error checking parcel access (${x}, ${y}, ${timestamp}, ${ethAddress}).`);
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const SCENE_LOOKBACK_TIME = (0, ms_1.default)('5m');
|
|
209
|
+
const { entity } = deployment;
|
|
210
|
+
const { pointers, timestamp } = entity;
|
|
211
|
+
const ethAddress = externalCalls.ownerAddress(deployment.auditInfo);
|
|
212
|
+
const errors = [];
|
|
213
|
+
const lowerCasePointers = pointers.map((pointer) => pointer.toLowerCase());
|
|
214
|
+
for (const pointer of lowerCasePointers) {
|
|
215
|
+
const pointerParts = pointer.split(',');
|
|
216
|
+
if (pointerParts.length === 2) {
|
|
217
|
+
const x = parseInt(pointerParts[0], 10);
|
|
218
|
+
const y = parseInt(pointerParts[1], 10);
|
|
219
|
+
try {
|
|
220
|
+
// 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)
|
|
221
|
+
const hasAccess = (await checkParcelAccess(x, y, timestamp, ethAddress, externalCalls)) ||
|
|
222
|
+
(await checkParcelAccess(x, y, timestamp - SCENE_LOOKBACK_TIME, ethAddress, externalCalls));
|
|
40
223
|
if (!hasAccess) {
|
|
41
224
|
errors.push(`The provided Eth Address does not have access to the following parcel: (${x},${y})`);
|
|
42
225
|
}
|
|
43
226
|
}
|
|
227
|
+
catch (e) {
|
|
228
|
+
errors.push(`The provided Eth Address does not have access to the following parcel: (${x},${y}). ${e}`);
|
|
229
|
+
}
|
|
44
230
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return (0, types_1.fromErrors)(`Cannot validate deployment`);
|
|
231
|
+
else {
|
|
232
|
+
errors.push(`Scene pointers should only contain two integers separated by a comma, for example (10,10) or (120,-45). Invalid pointer: ${pointer}`);
|
|
48
233
|
}
|
|
49
|
-
return (0, types_1.fromErrors)(...errors);
|
|
50
234
|
}
|
|
51
|
-
|
|
235
|
+
return (0, types_1.fromErrors)(...errors);
|
|
236
|
+
}
|
|
237
|
+
exports.scenes = scenes;
|
|
238
|
+
/** @internal */
|
|
239
|
+
async function retry(execution, attempts, waitTime = '1s', failedAttemptCallback) {
|
|
240
|
+
while (attempts > 0) {
|
|
241
|
+
try {
|
|
242
|
+
return await execution();
|
|
243
|
+
// ^^^^^ never remove this "await" keyword, otherwise this function won't
|
|
244
|
+
// catch the exception and perform the retries
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
attempts--;
|
|
248
|
+
if (attempts > 0) {
|
|
249
|
+
if (failedAttemptCallback) {
|
|
250
|
+
failedAttemptCallback(attempts);
|
|
251
|
+
}
|
|
252
|
+
await new Promise((res) => setTimeout(res, (0, ms_1.default)(waitTime)));
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
throw new Error('Please specify more than one attempt for the retry function');
|
|
260
|
+
}
|
|
52
261
|
//# sourceMappingURL=scenes.js.map
|
|
@@ -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,4CAAmB;AACnB,uCAAyG;AAgCzG;;;GAGG;AACI,KAAK,UAAU,MAAM,CAC1B,UAAoF,EACpF,UAAgC;IAEhC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,UAAU,CAAA;IACrD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAA;IACxD,MAAM,iBAAiB,GAAG,KAAK,EAC7B,KAAiB,EACjB,QAAoB,EACpB,SAAoB,EACM,EAAE;QAC5B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;YAcN,CAAA;QAER,MAAM,SAAS,GAAG;YAChB,KAAK;YACL,QAAQ;YACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,oBAAoB;SAC7D,CAAA;QAED,IAAI;YACF,OAAO,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,gBAAgB;AAChB,KAAK,UAAU,KAAK,CAClB,SAA2B,EAC3B,QAAgB,EAChB,WAAmB,IAAI,EACvB,qBAAsD;IAEtD,OAAO,QAAQ,GAAG,CAAC,EAAE;QACnB,IAAI;YACF,OAAO,MAAM,SAAS,EAAE,CAAA;YACxB,6EAA6E;YAC7E,wDAAwD;SACzD;QAAC,OAAO,KAAK,EAAE;YACd,QAAQ,EAAE,CAAA;YACV,IAAI,QAAQ,GAAG,CAAC,EAAE;gBAChB,IAAI,qBAAqB,EAAE;oBACzB,qBAAqB,CAAC,QAAQ,CAAC,CAAA;iBAChC;gBACD,MAAM,IAAI,OAAO,CAAO,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,IAAA,YAAE,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;aAChE;iBAAM;gBACL,MAAM,KAAK,CAAA;aACZ;SACF;KACF;IACD,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;AAChF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentValidatorComponents, DeploymentToValidate } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Validate that the pointers are valid, and that the Ethereum address has write access to them
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare function stores(components: Pick<ContentValidatorComponents, 'externalCalls' | 'logs' | 'theGraphClient'>, deployment: DeploymentToValidate): Promise<import("../../types").ValidationResponse>;
|
|
7
7
|
//# sourceMappingURL=stores.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/stores.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/stores.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAwB,MAAM,aAAa,CAAA;AAUpG;;;GAGG;AACH,wBAAsB,MAAM,CAC1B,UAAU,EAAE,IAAI,CAAC,0BAA0B,EAAE,eAAe,GAAG,MAAM,GAAG,gBAAgB,CAAC,EACzF,UAAU,EAAE,oBAAoB,qDAsBjC"}
|
|
@@ -16,19 +16,18 @@ const parseUrnNoFail = async (pointer) => {
|
|
|
16
16
|
* Validate that the pointers are valid, and that the Ethereum address has write access to them
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
19
|
+
async function stores(components, deployment) {
|
|
20
|
+
const pointers = deployment.entity.pointers;
|
|
21
|
+
const ethAddress = components.externalCalls.ownerAddress(deployment.auditInfo);
|
|
22
|
+
if (pointers.length !== 1)
|
|
23
|
+
return (0, types_1.validationFailed)(`Only one pointer is allowed when you create a Store. Received: ${pointers}`);
|
|
24
|
+
const pointer = pointers[0].toLowerCase();
|
|
25
|
+
const offchainAsset = await parseUrnNoFail(pointer);
|
|
26
|
+
if (!offchainAsset)
|
|
27
|
+
return (0, types_1.validationFailed)(`Store pointers should be a urn, for example (urn:decentraland:off-chain:marketplace-stores:{address}). Invalid pointer: ${pointer}`);
|
|
28
|
+
if (offchainAsset.id !== ethAddress)
|
|
29
|
+
return (0, types_1.validationFailed)(`You can only alter your own store. The pointer address and the signer address are different (address:${offchainAsset.id.toLowerCase()} signer: ${ethAddress.toLowerCase()}).`);
|
|
30
|
+
return types_1.OK;
|
|
31
|
+
}
|
|
32
|
+
exports.stores = stores;
|
|
34
33
|
//# sourceMappingURL=stores.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stores.js","sourceRoot":"","sources":["../../../src/validations/access-checker/stores.ts"],"names":[],"m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|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
1
|
+
import { ContentValidatorComponents, DeploymentToValidate } from '../../types';
|
|
2
|
+
export declare function wearables(components: Pick<ContentValidatorComponents, 'externalCalls' | 'logs' | 'theGraphClient'>, deployment: DeploymentToValidate): Promise<import("../../types").ValidationResponse>;
|
|
3
3
|
//# sourceMappingURL=wearables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wearables.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/wearables.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"wearables.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/wearables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAG9E,wBAAsB,SAAS,CAC7B,UAAU,EAAE,IAAI,CAAC,0BAA0B,EAAE,eAAe,GAAG,MAAM,GAAG,gBAAgB,CAAC,EACzF,UAAU,EAAE,oBAAoB,qDAQjC"}
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wearables = void 0;
|
|
4
4
|
const items_1 = require("./items/items");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
5
|
+
async function wearables(components, deployment) {
|
|
6
|
+
return (0, items_1.itemsValidation)(components, deployment, [
|
|
7
|
+
'off-chain',
|
|
8
|
+
'blockchain-collection-v1-asset',
|
|
9
|
+
'blockchain-collection-v2-asset',
|
|
10
|
+
'blockchain-collection-third-party'
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
exports.wearables = wearables;
|
|
15
14
|
//# sourceMappingURL=wearables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wearables.js","sourceRoot":"","sources":["../../../src/validations/access-checker/wearables.ts"],"names":[],"mappings":";;;AACA,yCAA+C;
|
|
1
|
+
{"version":3,"file":"wearables.js","sourceRoot":"","sources":["../../../src/validations/access-checker/wearables.ts"],"names":[],"mappings":";;;AACA,yCAA+C;AAExC,KAAK,UAAU,SAAS,CAC7B,UAAyF,EACzF,UAAgC;IAEhC,OAAO,IAAA,uBAAe,EAAC,UAAU,EAAE,UAAU,EAAE;QAC7C,WAAW;QACX,gCAAgC;QAChC,gCAAgC;QAChC,mCAAmC;KACpC,CAAC,CAAA;AACJ,CAAC;AAVD,8BAUC"}
|