dcentraland 3.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (289) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +56 -0
  3. package/abi/EstateRegistry.json +1226 -0
  4. package/abi/LANDRegistry.json +1372 -0
  5. package/abi/MANAToken.json +410 -0
  6. package/dist/commands/build.d.ts +3 -0
  7. package/dist/commands/build.d.ts.map +1 -0
  8. package/dist/commands/build.js +108 -0
  9. package/dist/commands/build.js.map +1 -0
  10. package/dist/commands/coords.d.ts +3 -0
  11. package/dist/commands/coords.d.ts.map +1 -0
  12. package/dist/commands/coords.js +122 -0
  13. package/dist/commands/coords.js.map +1 -0
  14. package/dist/commands/deploy.d.ts +4 -0
  15. package/dist/commands/deploy.d.ts.map +1 -0
  16. package/dist/commands/deploy.js +280 -0
  17. package/dist/commands/deploy.js.map +1 -0
  18. package/dist/commands/export.d.ts +3 -0
  19. package/dist/commands/export.d.ts.map +1 -0
  20. package/dist/commands/export.js +20 -0
  21. package/dist/commands/export.js.map +1 -0
  22. package/dist/commands/index.d.ts +3 -0
  23. package/dist/commands/index.d.ts.map +1 -0
  24. package/dist/commands/index.js +19 -0
  25. package/dist/commands/index.js.map +1 -0
  26. package/dist/commands/info.d.ts +3 -0
  27. package/dist/commands/info.d.ts.map +1 -0
  28. package/dist/commands/info.js +186 -0
  29. package/dist/commands/info.js.map +1 -0
  30. package/dist/commands/init/help.d.ts +12 -0
  31. package/dist/commands/init/help.d.ts.map +1 -0
  32. package/dist/commands/init/help.js +41 -0
  33. package/dist/commands/init/help.js.map +1 -0
  34. package/dist/commands/init/index.d.ts +3 -0
  35. package/dist/commands/init/index.d.ts.map +1 -0
  36. package/dist/commands/init/index.js +96 -0
  37. package/dist/commands/init/index.js.map +1 -0
  38. package/dist/commands/init/library.d.ts +1 -0
  39. package/dist/commands/init/library.d.ts.map +1 -0
  40. package/dist/commands/init/library.js +2 -0
  41. package/dist/commands/init/library.js.map +1 -0
  42. package/dist/commands/init/repositories.d.ts +11 -0
  43. package/dist/commands/init/repositories.d.ts.map +1 -0
  44. package/dist/commands/init/repositories.js +40 -0
  45. package/dist/commands/init/repositories.js.map +1 -0
  46. package/dist/commands/init/scene.d.ts +3 -0
  47. package/dist/commands/init/scene.d.ts.map +1 -0
  48. package/dist/commands/init/scene.js +56 -0
  49. package/dist/commands/init/scene.js.map +1 -0
  50. package/dist/commands/init/types.d.ts +22 -0
  51. package/dist/commands/init/types.d.ts.map +1 -0
  52. package/dist/commands/init/types.js +3 -0
  53. package/dist/commands/init/types.js.map +1 -0
  54. package/dist/commands/init/utils.d.ts +6 -0
  55. package/dist/commands/init/utils.d.ts.map +1 -0
  56. package/dist/commands/init/utils.js +76 -0
  57. package/dist/commands/init/utils.js.map +1 -0
  58. package/dist/commands/install.d.ts +3 -0
  59. package/dist/commands/install.d.ts.map +1 -0
  60. package/dist/commands/install.js +92 -0
  61. package/dist/commands/install.js.map +1 -0
  62. package/dist/commands/pack.d.ts +3 -0
  63. package/dist/commands/pack.d.ts.map +1 -0
  64. package/dist/commands/pack.js +102 -0
  65. package/dist/commands/pack.js.map +1 -0
  66. package/dist/commands/start.d.ts +3 -0
  67. package/dist/commands/start.d.ts.map +1 -0
  68. package/dist/commands/start.js +235 -0
  69. package/dist/commands/start.js.map +1 -0
  70. package/dist/commands/status.d.ts +3 -0
  71. package/dist/commands/status.d.ts.map +1 -0
  72. package/dist/commands/status.js +80 -0
  73. package/dist/commands/status.js.map +1 -0
  74. package/dist/commands/workspace.d.ts +3 -0
  75. package/dist/commands/workspace.d.ts.map +1 -0
  76. package/dist/commands/workspace.js +81 -0
  77. package/dist/commands/workspace.js.map +1 -0
  78. package/dist/commands/world-acl.d.ts +22 -0
  79. package/dist/commands/world-acl.d.ts.map +1 -0
  80. package/dist/commands/world-acl.js +262 -0
  81. package/dist/commands/world-acl.js.map +1 -0
  82. package/dist/config.d.ts +31 -0
  83. package/dist/config.d.ts.map +1 -0
  84. package/dist/config.js +128 -0
  85. package/dist/config.js.map +1 -0
  86. package/dist/index.d.ts +3 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +21 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/lib/API.d.ts +23 -0
  91. package/dist/lib/API.d.ts.map +1 -0
  92. package/dist/lib/API.js +175 -0
  93. package/dist/lib/API.js.map +1 -0
  94. package/dist/lib/Decentraland.d.ts +75 -0
  95. package/dist/lib/Decentraland.d.ts.map +1 -0
  96. package/dist/lib/Decentraland.js +227 -0
  97. package/dist/lib/Decentraland.js.map +1 -0
  98. package/dist/lib/Ethereum.d.ts +52 -0
  99. package/dist/lib/Ethereum.d.ts.map +1 -0
  100. package/dist/lib/Ethereum.js +245 -0
  101. package/dist/lib/Ethereum.js.map +1 -0
  102. package/dist/lib/IEthereumDataProvider.d.ts +17 -0
  103. package/dist/lib/IEthereumDataProvider.d.ts.map +1 -0
  104. package/dist/lib/IEthereumDataProvider.js +3 -0
  105. package/dist/lib/IEthereumDataProvider.js.map +1 -0
  106. package/dist/lib/LinkerAPI.d.ts +28 -0
  107. package/dist/lib/LinkerAPI.d.ts.map +1 -0
  108. package/dist/lib/LinkerAPI.js +151 -0
  109. package/dist/lib/LinkerAPI.js.map +1 -0
  110. package/dist/lib/Preview.d.ts +17 -0
  111. package/dist/lib/Preview.d.ts.map +1 -0
  112. package/dist/lib/Preview.js +113 -0
  113. package/dist/lib/Preview.js.map +1 -0
  114. package/dist/lib/Project.d.ts +152 -0
  115. package/dist/lib/Project.d.ts.map +1 -0
  116. package/dist/lib/Project.js +446 -0
  117. package/dist/lib/Project.js.map +1 -0
  118. package/dist/lib/Workspace.d.ts +21 -0
  119. package/dist/lib/Workspace.d.ts.map +1 -0
  120. package/dist/lib/Workspace.js +140 -0
  121. package/dist/lib/Workspace.js.map +1 -0
  122. package/dist/lib/WorldsContentServer.d.ts +27 -0
  123. package/dist/lib/WorldsContentServer.d.ts.map +1 -0
  124. package/dist/lib/WorldsContentServer.js +79 -0
  125. package/dist/lib/WorldsContentServer.js.map +1 -0
  126. package/dist/lib/WorldsContentServerLinkerAPI.d.ts +21 -0
  127. package/dist/lib/WorldsContentServerLinkerAPI.d.ts.map +1 -0
  128. package/dist/lib/WorldsContentServerLinkerAPI.js +105 -0
  129. package/dist/lib/WorldsContentServerLinkerAPI.js.map +1 -0
  130. package/dist/lib/adapters/proto/broker.d.ts +2 -0
  131. package/dist/lib/adapters/proto/broker.d.ts.map +1 -0
  132. package/dist/lib/adapters/proto/broker.js +2189 -0
  133. package/dist/lib/adapters/proto/broker.js.map +1 -0
  134. package/dist/lib/adapters/proto/comms.d.ts +2 -0
  135. package/dist/lib/adapters/proto/comms.d.ts.map +1 -0
  136. package/dist/lib/adapters/proto/comms.js +965 -0
  137. package/dist/lib/adapters/proto/comms.js.map +1 -0
  138. package/dist/lib/adapters/ws.d.ts +12 -0
  139. package/dist/lib/adapters/ws.d.ts.map +1 -0
  140. package/dist/lib/adapters/ws.js +20 -0
  141. package/dist/lib/adapters/ws.js.map +1 -0
  142. package/dist/lib/content/ContentService.d.ts +27 -0
  143. package/dist/lib/content/ContentService.d.ts.map +1 -0
  144. package/dist/lib/content/ContentService.js +60 -0
  145. package/dist/lib/content/ContentService.js.map +1 -0
  146. package/dist/lib/content/types.d.ts +12 -0
  147. package/dist/lib/content/types.d.ts.map +1 -0
  148. package/dist/lib/content/types.js +3 -0
  149. package/dist/lib/content/types.js.map +1 -0
  150. package/dist/lib/controllers/bff.d.ts +8 -0
  151. package/dist/lib/controllers/bff.d.ts.map +1 -0
  152. package/dist/lib/controllers/bff.js +58 -0
  153. package/dist/lib/controllers/bff.js.map +1 -0
  154. package/dist/lib/controllers/debugger.d.ts +4 -0
  155. package/dist/lib/controllers/debugger.d.ts.map +1 -0
  156. package/dist/lib/controllers/debugger.js +42 -0
  157. package/dist/lib/controllers/debugger.js.map +1 -0
  158. package/dist/lib/controllers/ecs6-endpoints.d.ts +11 -0
  159. package/dist/lib/controllers/ecs6-endpoints.d.ts.map +1 -0
  160. package/dist/lib/controllers/ecs6-endpoints.js +543 -0
  161. package/dist/lib/controllers/ecs6-endpoints.js.map +1 -0
  162. package/dist/lib/controllers/legacy-comms-v1.d.ts +7 -0
  163. package/dist/lib/controllers/legacy-comms-v1.d.ts.map +1 -0
  164. package/dist/lib/controllers/legacy-comms-v1.js +98 -0
  165. package/dist/lib/controllers/legacy-comms-v1.js.map +1 -0
  166. package/dist/lib/smartItems/buildSmartItem.d.ts +2 -0
  167. package/dist/lib/smartItems/buildSmartItem.d.ts.map +1 -0
  168. package/dist/lib/smartItems/buildSmartItem.js +18 -0
  169. package/dist/lib/smartItems/buildSmartItem.js.map +1 -0
  170. package/dist/lib/smartItems/packProject.d.ts +2 -0
  171. package/dist/lib/smartItems/packProject.d.ts.map +1 -0
  172. package/dist/lib/smartItems/packProject.js +31 -0
  173. package/dist/lib/smartItems/packProject.js.map +1 -0
  174. package/dist/main.d.ts +2 -0
  175. package/dist/main.d.ts.map +1 -0
  176. package/dist/main.js +151 -0
  177. package/dist/main.js.map +1 -0
  178. package/dist/project/installDependencies.d.ts +2 -0
  179. package/dist/project/installDependencies.d.ts.map +1 -0
  180. package/dist/project/installDependencies.js +57 -0
  181. package/dist/project/installDependencies.js.map +1 -0
  182. package/dist/project/isTypescriptProject.d.ts +2 -0
  183. package/dist/project/isTypescriptProject.d.ts.map +1 -0
  184. package/dist/project/isTypescriptProject.js +14 -0
  185. package/dist/project/isTypescriptProject.js.map +1 -0
  186. package/dist/project/projectInfo.d.ts +8 -0
  187. package/dist/project/projectInfo.d.ts.map +1 -0
  188. package/dist/project/projectInfo.js +89 -0
  189. package/dist/project/projectInfo.js.map +1 -0
  190. package/dist/project/updateBundleDependenciesField.d.ts +4 -0
  191. package/dist/project/updateBundleDependenciesField.d.ts.map +1 -0
  192. package/dist/project/updateBundleDependenciesField.js +67 -0
  193. package/dist/project/updateBundleDependenciesField.js.map +1 -0
  194. package/dist/sceneJson/index.d.ts +4 -0
  195. package/dist/sceneJson/index.d.ts.map +1 -0
  196. package/dist/sceneJson/index.js +24 -0
  197. package/dist/sceneJson/index.js.map +1 -0
  198. package/dist/sceneJson/lintSceneFile.d.ts +2 -0
  199. package/dist/sceneJson/lintSceneFile.d.ts.map +1 -0
  200. package/dist/sceneJson/lintSceneFile.js +13 -0
  201. package/dist/sceneJson/lintSceneFile.js.map +1 -0
  202. package/dist/sceneJson/utils.d.ts +3 -0
  203. package/dist/sceneJson/utils.d.ts.map +1 -0
  204. package/dist/sceneJson/utils.js +66 -0
  205. package/dist/sceneJson/utils.js.map +1 -0
  206. package/dist/utils/analytics.d.ts +42 -0
  207. package/dist/utils/analytics.d.ts.map +1 -0
  208. package/dist/utils/analytics.js +111 -0
  209. package/dist/utils/analytics.js.map +1 -0
  210. package/dist/utils/buildProject.d.ts +2 -0
  211. package/dist/utils/buildProject.d.ts.map +1 -0
  212. package/dist/utils/buildProject.js +26 -0
  213. package/dist/utils/buildProject.js.map +1 -0
  214. package/dist/utils/catalystPointers.d.ts +20 -0
  215. package/dist/utils/catalystPointers.d.ts.map +1 -0
  216. package/dist/utils/catalystPointers.js +51 -0
  217. package/dist/utils/catalystPointers.js.map +1 -0
  218. package/dist/utils/coordinateHelpers.d.ts +65 -0
  219. package/dist/utils/coordinateHelpers.d.ts.map +1 -0
  220. package/dist/utils/coordinateHelpers.js +126 -0
  221. package/dist/utils/coordinateHelpers.js.map +1 -0
  222. package/dist/utils/download.d.ts +3 -0
  223. package/dist/utils/download.d.ts.map +1 -0
  224. package/dist/utils/download.js +42 -0
  225. package/dist/utils/download.js.map +1 -0
  226. package/dist/utils/env.d.ts +6 -0
  227. package/dist/utils/env.d.ts.map +1 -0
  228. package/dist/utils/env.js +31 -0
  229. package/dist/utils/env.js.map +1 -0
  230. package/dist/utils/errors.d.ts +18 -0
  231. package/dist/utils/errors.d.ts.map +1 -0
  232. package/dist/utils/errors.js +27 -0
  233. package/dist/utils/errors.js.map +1 -0
  234. package/dist/utils/filesystem.d.ts +41 -0
  235. package/dist/utils/filesystem.d.ts.map +1 -0
  236. package/dist/utils/filesystem.js +84 -0
  237. package/dist/utils/filesystem.js.map +1 -0
  238. package/dist/utils/getDummyMappings.d.ts +3 -0
  239. package/dist/utils/getDummyMappings.d.ts.map +1 -0
  240. package/dist/utils/getDummyMappings.js +19 -0
  241. package/dist/utils/getDummyMappings.js.map +1 -0
  242. package/dist/utils/getProjectFilePaths.d.ts +2 -0
  243. package/dist/utils/getProjectFilePaths.d.ts.map +1 -0
  244. package/dist/utils/getProjectFilePaths.js +40 -0
  245. package/dist/utils/getProjectFilePaths.js.map +1 -0
  246. package/dist/utils/index.d.ts +11 -0
  247. package/dist/utils/index.d.ts.map +1 -0
  248. package/dist/utils/index.js +33 -0
  249. package/dist/utils/index.js.map +1 -0
  250. package/dist/utils/installedDependencies.d.ts +6 -0
  251. package/dist/utils/installedDependencies.d.ts.map +1 -0
  252. package/dist/utils/installedDependencies.js +44 -0
  253. package/dist/utils/installedDependencies.js.map +1 -0
  254. package/dist/utils/land.d.ts +4 -0
  255. package/dist/utils/land.d.ts.map +1 -0
  256. package/dist/utils/land.js +35 -0
  257. package/dist/utils/land.js.map +1 -0
  258. package/dist/utils/logging.d.ts +19 -0
  259. package/dist/utils/logging.d.ts.map +1 -0
  260. package/dist/utils/logging.js +97 -0
  261. package/dist/utils/logging.js.map +1 -0
  262. package/dist/utils/moduleHelpers.d.ts +22 -0
  263. package/dist/utils/moduleHelpers.d.ts.map +1 -0
  264. package/dist/utils/moduleHelpers.js +163 -0
  265. package/dist/utils/moduleHelpers.js.map +1 -0
  266. package/dist/utils/nodeAndNpmVersion.d.ts +5 -0
  267. package/dist/utils/nodeAndNpmVersion.d.ts.map +1 -0
  268. package/dist/utils/nodeAndNpmVersion.js +64 -0
  269. package/dist/utils/nodeAndNpmVersion.js.map +1 -0
  270. package/dist/utils/pathsExistOnDir.d.ts +2 -0
  271. package/dist/utils/pathsExistOnDir.d.ts.map +1 -0
  272. package/dist/utils/pathsExistOnDir.js +12 -0
  273. package/dist/utils/pathsExistOnDir.js.map +1 -0
  274. package/dist/utils/project.d.ts +29 -0
  275. package/dist/utils/project.d.ts.map +1 -0
  276. package/dist/utils/project.js +48 -0
  277. package/dist/utils/project.js.map +1 -0
  278. package/dist/utils/shellCommands.d.ts +19 -0
  279. package/dist/utils/shellCommands.d.ts.map +1 -0
  280. package/dist/utils/shellCommands.js +73 -0
  281. package/dist/utils/shellCommands.js.map +1 -0
  282. package/dist/utils/spinner.d.ts +6 -0
  283. package/dist/utils/spinner.d.ts.map +1 -0
  284. package/dist/utils/spinner.js +58 -0
  285. package/dist/utils/spinner.js.map +1 -0
  286. package/package.json +115 -0
  287. package/raim7jnk.cjs +1 -0
  288. package/samples/workspace/Dockerfile +21 -0
  289. package/samples/workspace/package.json +16 -0
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.getAuthHeaders = exports.AUTH_METADATA_HEADER = exports.AUTH_TIMESTAMP_HEADER = exports.AUTH_CHAIN_HEADER_PREFIX = exports.WorldPermissionType = exports.main = exports.help = void 0;
30
+ const chalk_1 = __importDefault(require("chalk"));
31
+ const errors_1 = require("../utils/errors");
32
+ const spinner = __importStar(require("../utils/spinner"));
33
+ const node_fetch_1 = __importDefault(require("node-fetch"));
34
+ const arg_1 = __importDefault(require("arg"));
35
+ const opn_1 = __importDefault(require("opn"));
36
+ const crypto_1 = require("@dcl/crypto");
37
+ const WorldsContentServer_1 = require("../lib/WorldsContentServer");
38
+ const analytics_1 = require("../utils/analytics");
39
+ const spec = {
40
+ '--help': Boolean,
41
+ '-h': '--help',
42
+ '--https': Boolean,
43
+ '--target-content': String,
44
+ '-t': '--target-content',
45
+ '--port': String,
46
+ '-p': '--port'
47
+ };
48
+ function help() {
49
+ return `
50
+ Usage: ${chalk_1.default.bold('dcl world-acl [world-name] SUBCOMMAND [options]')}
51
+
52
+ ${chalk_1.default.dim('Sub commands:')}
53
+ show List all addresses allowed to deploy a scene to a specified world.
54
+ grant addr Grant permission to new address to deploy a scene to a specified world.
55
+ revoke addr Remove permission for given address to deploy a scene to a specified world.
56
+
57
+
58
+ ${chalk_1.default.dim('Options:')}
59
+
60
+ -h, --help Displays complete help
61
+ -p, --port [port] Select a custom port for the linker app (for signing with browser wallet)
62
+ -t, --target-content [url] Specifies the base URL for the target Worlds Content Server. Example: 'https://worlds-content-server.decentraland.org'.
63
+
64
+ ${chalk_1.default.dim('Examples:')}
65
+ - Show which addresses were given permission to deploy name.dcl.eth
66
+ ${chalk_1.default.green('$ dcl world-acl name.dcl.eth show')}
67
+
68
+ - Grant address 0x1 permission to deploy name.dcl.eth
69
+ ${chalk_1.default.green('$ dcl world-acl name.dcl.eth grant 0x1')}
70
+
71
+ - Revoke address 0x1 permission to deploy name.dcl.eth
72
+ ${chalk_1.default.green('$ dcl world-acl name.dcl.eth revoke 0x1')}
73
+ `;
74
+ }
75
+ exports.help = help;
76
+ async function main() {
77
+ if (process.argv.length <= 4) {
78
+ (0, errors_1.fail)(errors_1.ErrorType.WORLD_CONTENT_SERVER_ERROR, `The subcommand is not recognized`);
79
+ }
80
+ const args = (0, arg_1.default)(spec);
81
+ if (!args['--target-content']) {
82
+ args['--target-content'] = 'https://worlds-content-server.decentraland.org';
83
+ }
84
+ analytics_1.Analytics.worldAcl({
85
+ action: args._[2].toLowerCase()
86
+ });
87
+ const subcommandList = {
88
+ show: showAcl,
89
+ grant: grantAcl,
90
+ revoke: revokeAcl,
91
+ help: async () => console.log(help())
92
+ };
93
+ const subcommand = args._[2].toLowerCase();
94
+ if (subcommand in subcommandList) {
95
+ await subcommandList[subcommand](args);
96
+ }
97
+ else {
98
+ (0, errors_1.fail)(errors_1.ErrorType.WORLD_CONTENT_SERVER_ERROR, `The subcommand ${subcommand} is not recognized`);
99
+ }
100
+ }
101
+ exports.main = main;
102
+ class HTTPResponseError extends Error {
103
+ constructor(response) {
104
+ super(`HTTP Error Response: ${response.status} ${response.statusText} for URL ${response.url}`);
105
+ this.response = response;
106
+ }
107
+ }
108
+ const checkStatus = (response) => {
109
+ if (response.ok) {
110
+ // response.status >= 200 && response.status < 300
111
+ return response;
112
+ }
113
+ throw new HTTPResponseError(response);
114
+ };
115
+ var WorldPermissionType;
116
+ (function (WorldPermissionType) {
117
+ WorldPermissionType["Unrestricted"] = "unrestricted";
118
+ WorldPermissionType["AllowList"] = "allow-list";
119
+ })(WorldPermissionType = exports.WorldPermissionType || (exports.WorldPermissionType = {}));
120
+ async function fetchAcl(worldName, targetContent) {
121
+ spinner.create(`Fetching acl for world ${worldName}`);
122
+ try {
123
+ const data = await (0, node_fetch_1.default)(`${targetContent}/world/${worldName}/permissions`)
124
+ .then(checkStatus)
125
+ .then((res) => res.json());
126
+ spinner.succeed();
127
+ return data.permissions.deployment;
128
+ }
129
+ catch (error) {
130
+ spinner.fail(await error.response.text());
131
+ throw error;
132
+ }
133
+ }
134
+ async function storeAcl(worldName, headers, targetContent, path, method) {
135
+ spinner.create(`Storing acl for world ${worldName}`);
136
+ try {
137
+ await (0, node_fetch_1.default)(`${targetContent}${path}`, {
138
+ method: method,
139
+ headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' })
140
+ }).then(checkStatus);
141
+ spinner.succeed(`Stored acl for world ${worldName}`);
142
+ return true;
143
+ }
144
+ catch (error) {
145
+ const message = error.response.headers.get('content-type') === 'application/json'
146
+ ? (await error.response.json()).message
147
+ : await error.response.text();
148
+ spinner.fail(message);
149
+ throw Error(message);
150
+ }
151
+ }
152
+ function displayPermissionToConsole(data, worldName) {
153
+ if (data.wallets.length === 0) {
154
+ console.log(`${chalk_1.default.dim('Only the owner of')} ${chalk_1.default.bold(worldName)} ${chalk_1.default.dim('can deploy scenes under that name.')}`);
155
+ }
156
+ else {
157
+ console.log(`${chalk_1.default.dim('The following addresses are authorized to deploy scenes under')} ${chalk_1.default.bold(worldName)}${chalk_1.default.dim(':')}`);
158
+ data.wallets.forEach((address) => {
159
+ console.log(` ${chalk_1.default.bold(address)}`);
160
+ });
161
+ }
162
+ }
163
+ async function showAcl(args) {
164
+ const worldName = args._[1];
165
+ const targetContent = args['--target-content'];
166
+ try {
167
+ const data = await fetchAcl(worldName, targetContent);
168
+ displayPermissionToConsole(data, worldName);
169
+ }
170
+ catch (_) {
171
+ process.exit(1);
172
+ }
173
+ }
174
+ async function grantAcl(args) {
175
+ const worldName = args._[1];
176
+ const addresses = args._.slice(3);
177
+ try {
178
+ if (addresses.length > 1) {
179
+ (0, errors_1.fail)(errors_1.ErrorType.WORLD_CONTENT_SERVER_ERROR, `Only one address can be granted at a time.`);
180
+ }
181
+ await signAndStoreAcl(args, { resource: worldName, allowed: addresses[0], method: 'put' });
182
+ }
183
+ catch (error) {
184
+ spinner.fail(error.message);
185
+ throw Error(error.message);
186
+ }
187
+ }
188
+ async function revokeAcl(args) {
189
+ const worldName = args._[1];
190
+ const addresses = args._.slice(3);
191
+ try {
192
+ if (addresses.length > 1) {
193
+ (0, errors_1.fail)(errors_1.ErrorType.WORLD_CONTENT_SERVER_ERROR, `Only one address can be revoke at a time.`);
194
+ }
195
+ await signAndStoreAcl(args, { resource: worldName, allowed: addresses[0], method: 'delete' });
196
+ }
197
+ catch (error) {
198
+ spinner.fail(error.message);
199
+ throw Error(error.message);
200
+ }
201
+ }
202
+ async function signAndStoreAcl(args, acl) {
203
+ const path = `/world/${acl.resource}/permissions/deployment/${acl.allowed}`;
204
+ const timestamp = Date.now().toString();
205
+ const payload = [acl.method, path, timestamp, '{}'].join(':').toLowerCase();
206
+ const port = args['--port'];
207
+ const parsedPort = port ? parseInt(port, 10) : void 0;
208
+ const linkerPort = parsedPort && Number.isInteger(parsedPort) ? parsedPort : void 0;
209
+ const targetContent = args['--target-content'];
210
+ const worldsContentServer = new WorldsContentServer_1.WorldsContentServer({
211
+ worldName: acl.resource,
212
+ allowed: [acl.allowed],
213
+ oldAllowed: [],
214
+ isHttps: !!args['--https'],
215
+ targetContent,
216
+ linkerPort,
217
+ method: acl.method
218
+ });
219
+ worldsContentServer.on('link:ready', ({ url }) => {
220
+ console.log(chalk_1.default.bold('You need to sign the acl:'));
221
+ spinner.create(`Signing app ready at ${url}`);
222
+ setTimeout(async () => {
223
+ try {
224
+ await (0, opn_1.default)(`${url}/acl`);
225
+ }
226
+ catch (e) {
227
+ console.log(`Unable to open browser automatically`);
228
+ }
229
+ }, 5000);
230
+ worldsContentServer.on('link:success', ({ address, signature }) => {
231
+ spinner.succeed(`ACL successfully signed.`);
232
+ console.log(`${chalk_1.default.bold('Address:')} ${address}`);
233
+ console.log(`${chalk_1.default.bold('Signature:')} ${signature}`);
234
+ });
235
+ });
236
+ const { signature, address } = await worldsContentServer.getAddressAndSignature(payload);
237
+ const authChain = crypto_1.Authenticator.createSimpleAuthChain(payload, address, signature);
238
+ const headers = getAuthHeaders(authChain, timestamp);
239
+ try {
240
+ await storeAcl(acl.resource, headers, targetContent, path, acl.method);
241
+ const data = await fetchAcl(acl.resource, targetContent);
242
+ displayPermissionToConsole(data, acl.resource);
243
+ }
244
+ catch (error) {
245
+ process.exit(1);
246
+ }
247
+ process.exit();
248
+ }
249
+ exports.AUTH_CHAIN_HEADER_PREFIX = 'x-identity-auth-chain-';
250
+ exports.AUTH_TIMESTAMP_HEADER = 'x-identity-timestamp';
251
+ exports.AUTH_METADATA_HEADER = 'x-identity-metadata';
252
+ function getAuthHeaders(authChain, timestamp) {
253
+ const headers = {};
254
+ authChain.forEach((link, index) => {
255
+ headers[`${exports.AUTH_CHAIN_HEADER_PREFIX}${index}`] = JSON.stringify(link);
256
+ });
257
+ headers[exports.AUTH_TIMESTAMP_HEADER] = timestamp;
258
+ headers[exports.AUTH_METADATA_HEADER] = JSON.stringify({});
259
+ return headers;
260
+ }
261
+ exports.getAuthHeaders = getAuthHeaders;
262
+ //# sourceMappingURL=world-acl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world-acl.js","sourceRoot":"","sources":["../../src/commands/world-acl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AAEzB,4CAAiD;AACjD,0DAA2C;AAC3C,4DAA4C;AAE5C,8CAAqB;AACrB,8CAAqB;AACrB,wCAA2C;AAC3C,oEAAgE;AAEhE,kDAA8C;AAE9C,MAAM,IAAI,GAAG;IACX,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,OAAO;IAClB,kBAAkB,EAAE,MAAM;IAC1B,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,QAAQ;CACf,CAAA;AAED,SAAgB,IAAI;IAClB,OAAO;WACE,eAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC;;MAElE,eAAK,CAAC,GAAG,CAAC,eAAe,CAAC;;;;;;MAM1B,eAAK,CAAC,GAAG,CAAC,UAAU,CAAC;;;;;;MAMrB,eA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o = {
2
+ fileExists?: boolean;
3
+ userId: string;
4
+ trackStats: boolean;
5
+ provider?: string;
6
+ MANAToken?: string;
7
+ LANDRegistry?: string;
8
+ EstateRegistry?: string;
9
+ catalystUrl?: string;
10
+ dclApiUrl?: string;
11
+ segmentKey?: string;
12
+ };
13
+ /**
14
+ * Creates the `.dclinfo` file in the HOME directory
15
+ */
16
+ export declare function createDCLInfo(dclInfo: DCLInfo): Promise<void>;
17
+ /**
18
+ * Add new configuration to `.dclinfo` file
19
+ */
20
+ export declare function writeDCLInfo(newInfo: DCLInfo): Promise<void>;
21
+ /**
22
+ * Reads `.dclinfo` file and loads it in-memory to be sync-obtained with `getDCLInfo()` function
23
+ */
24
+ export declare function loadConfig(network: string): Promise<DCLInfo>;
25
+ /**
26
+ * Returns the contents of the `.dclinfo` file. It needs to be loaded first with `loadConfig()` function
27
+ */
28
+ export declare function getDCLInfo(): DCLInfo;
29
+ export declare function getConfig(network?: string): DCLInfo;
30
+ export declare function getCustomConfig(): Partial<DCLInfo>;
31
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,oBAAY,OAAO,GAAG;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAyBD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,iBAG7C;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,iBAElD;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAIlE;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,wBAAgB,SAAS,CAAC,OAAO,GAAE,MAAoB,GAAG,OAAO,CAMhE;AAED,wBAAgB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAIlD"}
package/dist/config.js ADDED
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getCustomConfig = exports.getConfig = exports.getDCLInfo = exports.loadConfig = exports.writeDCLInfo = exports.createDCLInfo = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const filesystem_1 = require("./utils/filesystem");
9
+ const utils_1 = require("./utils");
10
+ const moduleHelpers_1 = require("./utils/moduleHelpers");
11
+ const env_1 = require("./utils/env");
12
+ let networkFlag = 'mainnet';
13
+ let config;
14
+ /**
15
+ * Returns the path to the `.dclinfo` file located in the local HOME folder
16
+ */
17
+ function getDCLInfoPath() {
18
+ return path_1.default.resolve((0, filesystem_1.getUserHome)(), '.dclinfo');
19
+ }
20
+ /**
21
+ * Reads the contents of the `.dclinfo` file
22
+ */
23
+ async function readDCLInfo() {
24
+ const filePath = getDCLInfoPath();
25
+ try {
26
+ const file = await (0, filesystem_1.readJSON)(filePath);
27
+ return file;
28
+ }
29
+ catch (e) {
30
+ return null;
31
+ }
32
+ }
33
+ /**
34
+ * Creates the `.dclinfo` file in the HOME directory
35
+ */
36
+ function createDCLInfo(dclInfo) {
37
+ config = dclInfo;
38
+ return (0, filesystem_1.writeJSON)(getDCLInfoPath(), dclInfo);
39
+ }
40
+ exports.createDCLInfo = createDCLInfo;
41
+ /**
42
+ * Add new configuration to `.dclinfo` file
43
+ */
44
+ async function writeDCLInfo(newInfo) {
45
+ return (0, filesystem_1.writeJSON)(getDCLInfoPath(), Object.assign(Object.assign({}, config), { newInfo }));
46
+ }
47
+ exports.writeDCLInfo = writeDCLInfo;
48
+ /**
49
+ * Reads `.dclinfo` file and loads it in-memory to be sync-obtained with `getDCLInfo()` function
50
+ */
51
+ async function loadConfig(network) {
52
+ networkFlag = network;
53
+ config = (await readDCLInfo());
54
+ return config;
55
+ }
56
+ exports.loadConfig = loadConfig;
57
+ /**
58
+ * Returns the contents of the `.dclinfo` file. It needs to be loaded first with `loadConfig()` function
59
+ */
60
+ function getDCLInfo() {
61
+ return config;
62
+ }
63
+ exports.getDCLInfo = getDCLInfo;
64
+ function getConfig(network = networkFlag) {
65
+ const envConfig = getEnvConfig();
66
+ const dclInfoConfig = getDclInfoConfig();
67
+ const defaultConfig = getDefaultConfig(network);
68
+ const config = Object.assign(Object.assign(Object.assign({}, defaultConfig), dclInfoConfig), envConfig);
69
+ return config;
70
+ }
71
+ exports.getConfig = getConfig;
72
+ function getCustomConfig() {
73
+ const envConfig = getEnvConfig();
74
+ const dclInfoConfig = getDclInfoConfig();
75
+ return Object.assign(Object.assign({}, dclInfoConfig), envConfig);
76
+ }
77
+ exports.getCustomConfig = getCustomConfig;
78
+ function getDefaultConfig(network) {
79
+ const isMainnet = network === 'mainnet';
80
+ return {
81
+ userId: '',
82
+ trackStats: false,
83
+ provider: (0, env_1.isDevelopment)() ? 'https://sepolia.infura.io/' : 'https://mainnet.infura.io/',
84
+ MANAToken: isMainnet ? '0x0f5d2fb29fb7d3cfee444a200298f468908cc942' : '0xfa04d2e2ba9aec166c93dfeeba7427b2303befa9',
85
+ LANDRegistry: isMainnet
86
+ ? '0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d'
87
+ : '0x42f4ba48791e2de32f5fbf553441c2672864bb33',
88
+ EstateRegistry: isMainnet
89
+ ? '0x959e104e1a4db6317fa58f8295f586e1a978c297'
90
+ : '0x369a7fbe718c870c79f99fb423882e8dd8b20486',
91
+ catalystUrl: isMainnet ? 'https://peer.decentraland.org' : 'https://peer-ue-2.decentraland.zone',
92
+ dclApiUrl: isMainnet
93
+ ? 'https://subgraph.decentraland.org/land-manager'
94
+ : 'https://api.studio.thegraph.com/query/49472/land-manager-sepolia/version/latest',
95
+ segmentKey: (0, moduleHelpers_1.isStableVersion)() && !(0, env_1.isDevelopment)() ? 'sFdziRVDJo0taOnGzTZwafEL9nLIANZ3' : 'mjCV5Dc4VAKXLJAH5g7LyHyW1jrIR3to'
96
+ };
97
+ }
98
+ function getDclInfoConfig() {
99
+ const dclInfo = getDCLInfo();
100
+ const fileExists = !!dclInfo;
101
+ if (!fileExists) {
102
+ return { fileExists };
103
+ }
104
+ const dclInfoConfig = {
105
+ fileExists,
106
+ userId: dclInfo.userId,
107
+ trackStats: !!dclInfo.trackStats,
108
+ MANAToken: dclInfo.MANAToken,
109
+ LANDRegistry: dclInfo.LANDRegistry,
110
+ EstateRegistry: dclInfo.EstateRegistry,
111
+ catalystUrl: dclInfo.catalystUrl,
112
+ segmentKey: dclInfo.segmentKey
113
+ };
114
+ return (0, utils_1.removeEmptyKeys)(dclInfoConfig);
115
+ }
116
+ function getEnvConfig() {
117
+ const { RPC_URL, MANA_TOKEN, LAND_REGISTRY, ESTATE_REGISTRY, CONTENT_URL, SEGMENT_KEY } = process.env;
118
+ const envConfig = {
119
+ provider: RPC_URL,
120
+ MANAToken: MANA_TOKEN,
121
+ LANDRegistry: LAND_REGISTRY,
122
+ EstateRegistry: ESTATE_REGISTRY,
123
+ contentUrl: CONTENT_URL,
124
+ segmentKey: SEGMENT_KEY
125
+ };
126
+ return (0, utils_1.removeEmptyKeys)(envConfig);
127
+ }
128
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEvB,mDAAqE;AACrE,mCAAyC;AACzC,yDAAuD;AAC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,GAAG;QACpB,UAAU;QACV,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU;QAChC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAA;IAED,OAAO,IAAA,uBAAe,EAAC,aAAa,CAAC,CAAA;AACvC,CAAC;AAED,SAAS,YAAY;IACnB,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;IAErG,MAAM,SAAS,GAAG;QAChB,QAAQ,EAAE,OAAO;QACjB,SAAS,EAAE,UAAU;QACrB,YAAY,EAAE,aAAa;QAC3B,cAAc,EAAE,eAAe;QAC/B,UAAU,EAAE,WAAW;QACvB,UAAU,EAAE,WAAW;KACxB,CAAA;IAED,OAAO,IAAA,uBAAe,EAAC,SAAS,CAAC,CAAA;AACnC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const main_1 = require("./main");
10
+ fs_1.default.readFile(path_1.default.resolve(__dirname, '../package.json'), 'utf8', (err, data) => {
11
+ if (err) {
12
+ console.error('There was an unexpected error.', err);
13
+ process.exit(1);
14
+ }
15
+ const { version } = JSON.parse(data);
16
+ (0, main_1.main)(version).catch((err) => {
17
+ console.error(err);
18
+ process.exit(1);
19
+ });
20
+ });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAmB;AACnB,gDAAuB;AAEvB,iCAA6B;AAE7B,YAAE,CAAC,QAAQ,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IAC5E,IAAI,GAAG,EAAE;QACP,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAA;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACpC,IAAA,WAAI,EAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { LANDData } from './Ethereum';
2
+ import { IEthereumDataProvider } from './IEthereumDataProvider';
3
+ import { Coords } from '../utils/coordinateHelpers';
4
+ export declare class API implements IEthereumDataProvider {
5
+ private readonly fetcher;
6
+ getEstateIdOfLand({ x, y }: Coords): Promise<number>;
7
+ getEstateData(estateId: number): Promise<LANDData>;
8
+ getEstateOwner(estateId: number): Promise<string>;
9
+ getEstateOperator(estateId: number): Promise<string>;
10
+ getEstateUpdateOperator(estateId: number): Promise<string>;
11
+ getLandOfEstate(estateId: number): Promise<Coords[]>;
12
+ getLandData({ x, y }: Coords): Promise<LANDData>;
13
+ getLandOwner({ x, y }: Coords): Promise<string>;
14
+ getLandOperator({ x, y }: Coords): Promise<string>;
15
+ getLandUpdateOperator({ x, y }: Coords): Promise<string>;
16
+ getLandOf(owner: string): Promise<Coords[]>;
17
+ getEstatesOf(owner: string): Promise<number[]>;
18
+ /**
19
+ * We are making paginated queries to the subgraph, sorting by id and asking for the next ones
20
+ */
21
+ private queryGraphPaginated;
22
+ }
23
+ //# sourceMappingURL=API.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"API.d.ts","sourceRoot":"","sources":["../../src/lib/API.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAMnD,qBAAa,GAAI,YAAW,qBAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAE3C,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAepD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBlD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAejD,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAapD,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAc1D,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBpD,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBhD,YAAY,CAAC,EAAE,CAAC,EAAE,CA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