@dcl/sdk-commands 7.1.7-4743900895.commit-dea19db → 7.1.7-4745039397.commit-a6aff2b

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.
@@ -3,18 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = exports.help = exports.args = void 0;
4
4
  const path_1 = require("path");
5
5
  const schemas_1 = require("@dcl/schemas");
6
- const dcl_catalyst_client_1 = require("dcl-catalyst-client");
7
6
  const crypto_1 = require("@dcl/crypto");
8
- const eth_connect_1 = require("eth-connect");
9
- const crypto_2 = require("@dcl/crypto/dist/crypto");
10
7
  const scene_validations_1 = require("../../logic/scene-validations");
11
8
  const args_1 = require("../../logic/args");
12
9
  const project_validations_1 = require("../../logic/project-validations");
13
- const api_1 = require("./linker-dapp/api");
14
10
  const error_1 = require("../../logic/error");
15
11
  const beautiful_logs_1 = require("../../logic/beautiful-logs");
16
- const account_1 = require("../../logic/account");
17
12
  const project_files_1 = require("../../logic/project-files");
13
+ const utils_1 = require("./utils");
14
+ const dcl_catalyst_client_1 = require("dcl-catalyst-client");
18
15
  exports.args = (0, args_1.declareArgs)({
19
16
  '--dir': String,
20
17
  '--help': Boolean,
@@ -89,15 +86,16 @@ async function main(options) {
89
86
  });
90
87
  // Signing message
91
88
  const messageToSign = entityId;
92
- const { signature, address, chainId } = await getAddressAndSignature(options.components, messageToSign, sceneJson, files, {
89
+ const { linkerResponse, program } = await (0, utils_1.getAddressAndSignature)(options.components, messageToSign, sceneJson, files, {
93
90
  openBrowser,
94
91
  linkerPort,
95
92
  isHttps: !!options.args['--https'],
96
93
  skipValidations: !!options.args['--skip-validations'] || !!options.args['--target'] || !!options.args['--target-content']
97
94
  });
95
+ const { address, signature, chainId } = await linkerResponse;
98
96
  const authChain = crypto_1.Authenticator.createSimpleAuthChain(entityId, address, signature);
99
97
  // Uploading data
100
- const catalyst = await getCatalyst(options.args['--target'], options.args['--target-content']);
98
+ const catalyst = await (0, utils_1.getCatalyst)(options.args['--target'], options.args['--target-content']);
101
99
  (0, beautiful_logs_1.printProgressInfo)(options.components.logger, `Uploading data to: ${catalyst.getContentUrl()}...`);
102
100
  const deployData = { entityId, files: entityFiles, authChain };
103
101
  const position = sceneJson.scene.base;
@@ -117,24 +115,9 @@ async function main(options) {
117
115
  options.components.logger.error(e);
118
116
  options.components.analytics.track('Scene deploy failure', { ...trackProps, error: e.message ?? '' });
119
117
  }
118
+ finally {
119
+ await program?.stop();
120
+ }
120
121
  options.components.analytics.track('Scene deploy success', { ...trackProps, dependencies });
121
122
  }
122
123
  exports.main = main;
123
- async function getCatalyst(target, targetContent) {
124
- if (target) {
125
- return new dcl_catalyst_client_1.CatalystClient({ catalystUrl: target.endsWith('/') ? target.slice(0, -1) : target });
126
- }
127
- if (targetContent) {
128
- return new dcl_catalyst_client_1.ContentClient({ contentUrl: targetContent });
129
- }
130
- return dcl_catalyst_client_1.CatalystClient.connectedToCatalystIn({ network: 'mainnet' });
131
- }
132
- async function getAddressAndSignature(components, messageToSign, scene, files, linkOptions) {
133
- if (process.env.DCL_PRIVATE_KEY) {
134
- const wallet = (0, account_1.createWallet)(process.env.DCL_PRIVATE_KEY);
135
- const signature = (0, crypto_2.ethSign)((0, eth_connect_1.hexToBytes)(wallet.privateKey), messageToSign);
136
- return { signature, address: wallet.address };
137
- }
138
- const { linkerPort, ...opts } = linkOptions;
139
- return (0, api_1.runLinkerApp)(components, scene, files, linkerPort, messageToSign, opts);
140
- }
@@ -1,3 +1,4 @@
1
+ import { Lifecycle } from '@well-known-components/interfaces';
1
2
  import { ChainId, Scene } from '@dcl/schemas';
2
3
  import { IFile } from '../../../logic/scene-validations';
3
4
  import { CliComponents } from '../../../components';
@@ -21,4 +22,14 @@ export declare function runLinkerApp(cliComponents: Pick<CliComponents, 'fs' | '
21
22
  isHttps: boolean;
22
23
  skipValidations: boolean;
23
24
  openBrowser: boolean;
24
- }): Promise<LinkerResponse>;
25
+ }): Promise<{
26
+ program: Lifecycle.ComponentBasedProgram<{
27
+ config: import("@well-known-components/interfaces").IConfigComponent;
28
+ logs: import("@well-known-components/interfaces").ILoggerComponent;
29
+ server: import("@well-known-components/http-server").FullHttpServerComponent<object>;
30
+ fs: import("../../../components/fs").IFileSystemComponent;
31
+ fetch: import("../../../components/fetch").IFetchComponent;
32
+ logger: import("@well-known-components/interfaces").ILoggerComponent.ILogger;
33
+ }>;
34
+ linkerResponse: import("fp-future").IFuture<LinkerResponse>;
35
+ }>;
@@ -16,43 +16,43 @@ const get_free_port_1 = require("../../../logic/get-free-port");
16
16
  const beautiful_logs_1 = require("../../../logic/beautiful-logs");
17
17
  const routes_1 = require("./routes");
18
18
  const config_1 = require("../../../logic/config");
19
- function runLinkerApp(cliComponents, scene, files, port, rootCID, { isHttps, skipValidations, openBrowser }) {
20
- return new Promise(async (resolve) => {
21
- const resolvedPort = await (0, get_free_port_1.getPort)(port);
22
- const sceneInfo = await getSceneInfo(cliComponents, scene, rootCID, skipValidations);
23
- const protocol = isHttps ? 'https' : 'http';
24
- const queryParams = querystring_1.default.stringify(sceneInfo);
25
- const url = `${protocol}://localhost:${resolvedPort}`;
26
- const program = await interfaces_1.Lifecycle.run({
27
- async initComponents() {
28
- const config = (0, env_config_provider_1.createRecordConfigComponent)({
29
- HTTP_SERVER_PORT: resolvedPort.toString(),
30
- HTTP_SERVER_HOST: '0.0.0.0',
31
- ...process.env
32
- });
33
- const logs = await (0, logger_1.createConsoleLogComponent)({});
34
- const https = isHttps ? await getCredentials(cliComponents) : undefined;
35
- const server = await (0, http_server_1.createServerComponent)({ ...cliComponents, logs }, { https });
36
- return { ...cliComponents, config, logs, server };
37
- },
38
- async main({ components, startComponents }) {
39
- const { router, futureSignature } = (0, routes_1.setRoutes)(components, files, sceneInfo);
40
- components.server.setContext(components);
41
- components.server.use(router.allowedMethods());
42
- components.server.use(router.middleware());
43
- await startComponents();
44
- if (openBrowser)
45
- await browse(components, url, queryParams);
46
- const value = await futureSignature;
47
- (0, beautiful_logs_1.printSuccess)(components.logger, `\nContent successfully signed.`, '');
48
- components.logger.info(`Address: ${value.address}`);
49
- components.logger.info(`Signature: ${value.signature}`);
50
- components.logger.info(`Network: ${(0, schemas_1.getChainName)(value.chainId)}`);
51
- resolve(value);
52
- }
53
- });
54
- return program;
19
+ const fp_future_1 = __importDefault(require("fp-future"));
20
+ async function runLinkerApp(cliComponents, scene, files, port, rootCID, { isHttps, skipValidations, openBrowser }) {
21
+ const resolvedPort = await (0, get_free_port_1.getPort)(port);
22
+ const sceneInfo = await getSceneInfo(cliComponents, scene, rootCID, skipValidations);
23
+ const protocol = isHttps ? 'https' : 'http';
24
+ const queryParams = querystring_1.default.stringify(sceneInfo);
25
+ const url = `${protocol}://localhost:${resolvedPort}`;
26
+ const futureResponse = (0, fp_future_1.default)();
27
+ const program = await interfaces_1.Lifecycle.run({
28
+ async initComponents() {
29
+ const config = (0, env_config_provider_1.createRecordConfigComponent)({
30
+ HTTP_SERVER_PORT: resolvedPort.toString(),
31
+ HTTP_SERVER_HOST: '0.0.0.0',
32
+ ...process.env
33
+ });
34
+ const logs = await (0, logger_1.createConsoleLogComponent)({});
35
+ const https = isHttps ? await getCredentials(cliComponents) : undefined;
36
+ const server = await (0, http_server_1.createServerComponent)({ ...cliComponents, config, logs }, { https });
37
+ return { ...cliComponents, config, logs, server };
38
+ },
39
+ async main({ components, startComponents }) {
40
+ const { router, futureSignature } = (0, routes_1.setRoutes)(components, files, sceneInfo);
41
+ components.server.setContext(components);
42
+ components.server.use(router.allowedMethods());
43
+ components.server.use(router.middleware());
44
+ await startComponents();
45
+ if (openBrowser)
46
+ await browse(components, url, queryParams);
47
+ const value = await futureSignature;
48
+ (0, beautiful_logs_1.printSuccess)(components.logger, `\nContent successfully signed.`, '');
49
+ components.logger.info(`Address: ${value.address}`);
50
+ components.logger.info(`Signature: ${value.signature}`);
51
+ components.logger.info(`Network: ${(0, schemas_1.getChainName)(value.chainId)}`);
52
+ futureResponse.resolve(value);
53
+ }
55
54
  });
55
+ return { program, linkerResponse: futureResponse };
56
56
  }
57
57
  exports.runLinkerApp = runLinkerApp;
58
58
  async function browse({ logger }, url, params) {
@@ -65,7 +65,7 @@ async function browse({ logger }, url, params) {
65
65
  logger.error(`Unable to open browser automatically. Please manually navigate to:\n ${url}?${params}`);
66
66
  }
67
67
  }, 5000);
68
- logger.info(`Signing app ready at ${url}`);
68
+ logger.info(`Signing app ready at ${url}?${params}`);
69
69
  }
70
70
  async function getCredentials({ fs }) {
71
71
  const privateKey = await fs.readFile((0, path_1.resolve)(__dirname, '../../../certs/localhost.key'), 'utf-8');
@@ -0,0 +1,18 @@
1
+ import { Scene } from '@dcl/schemas';
2
+ import { Lifecycle } from '@well-known-components/interfaces';
3
+ import { CatalystClient, ContentClient } from 'dcl-catalyst-client';
4
+ import { CliComponents } from '../../components';
5
+ import { IFile } from '../../logic/scene-validations';
6
+ import { LinkerResponse } from './linker-dapp/api';
7
+ export declare function getCatalyst(target?: string, targetContent?: string): Promise<CatalystClient | ContentClient>;
8
+ interface LinkOptions {
9
+ openBrowser: boolean;
10
+ linkerPort?: number;
11
+ isHttps: boolean;
12
+ skipValidations: boolean;
13
+ }
14
+ export declare function getAddressAndSignature(components: CliComponents, messageToSign: string, scene: Scene, files: IFile[], linkOptions: LinkOptions): Promise<{
15
+ linkerResponse: Promise<LinkerResponse>;
16
+ program?: Lifecycle.ComponentBasedProgram<unknown>;
17
+ }>;
18
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAddressAndSignature = exports.getCatalyst = void 0;
4
+ const dcl_catalyst_client_1 = require("dcl-catalyst-client");
5
+ const eth_connect_1 = require("eth-connect");
6
+ const crypto_1 = require("@dcl/crypto/dist/crypto");
7
+ const api_1 = require("./linker-dapp/api");
8
+ const account_1 = require("../../logic/account");
9
+ async function getCatalyst(target, targetContent) {
10
+ if (target) {
11
+ return new dcl_catalyst_client_1.CatalystClient({ catalystUrl: target.endsWith('/') ? target.slice(0, -1) : target });
12
+ }
13
+ if (targetContent) {
14
+ return new dcl_catalyst_client_1.ContentClient({ contentUrl: targetContent });
15
+ }
16
+ return dcl_catalyst_client_1.CatalystClient.connectedToCatalystIn({ network: 'mainnet' });
17
+ }
18
+ exports.getCatalyst = getCatalyst;
19
+ async function getAddressAndSignature(components, messageToSign, scene, files, linkOptions) {
20
+ if (process.env.DCL_PRIVATE_KEY) {
21
+ const wallet = (0, account_1.createWallet)(process.env.DCL_PRIVATE_KEY);
22
+ const signature = (0, crypto_1.ethSign)((0, eth_connect_1.hexToBytes)(wallet.privateKey), messageToSign);
23
+ const linkerResponse = Promise.resolve({ signature, address: wallet.address });
24
+ return { linkerResponse };
25
+ }
26
+ const { linkerPort, ...opts } = linkOptions;
27
+ return (0, api_1.runLinkerApp)(components, scene, files, linkerPort, messageToSign, opts);
28
+ }
29
+ exports.getAddressAndSignature = getAddressAndSignature;
@@ -15,5 +15,5 @@ export declare function isEditor(): boolean;
15
15
  export declare function isCI(): boolean;
16
16
  export declare function getCatalystBaseUrl(components: Pick<CliComponents, 'config'>): Promise<string>;
17
17
  export declare function getSegmentKey(): "sFdziRVDJo0taOnGzTZwafEL9nLIANZ3" | "mjCV5Dc4VAKXLJAH5g7LyHyW1jrIR3to";
18
- export declare function getLandRegistry(components: Pick<CliComponents, 'config'>): Promise<string>;
19
- export declare function getEstateRegistry(components: Pick<CliComponents, 'config'>): Promise<string>;
18
+ export declare function getLandRegistry(components: Pick<CliComponents, 'config'>): Promise<string | undefined>;
19
+ export declare function getEstateRegistry(components: Pick<CliComponents, 'config'>): Promise<string | undefined>;
@@ -58,11 +58,11 @@ function getSegmentKey() {
58
58
  exports.getSegmentKey = getSegmentKey;
59
59
  /* istanbul ignore next */
60
60
  async function getLandRegistry(components) {
61
- return (0, config_1.requireStringConfig)(components, 'DCL_LAND_REGISTRY_ADDRESS');
61
+ return (0, config_1.readStringConfig)(components, 'DCL_LAND_REGISTRY_ADDRESS');
62
62
  }
63
63
  exports.getLandRegistry = getLandRegistry;
64
64
  /* istanbul ignore next */
65
65
  async function getEstateRegistry(components) {
66
- return (0, config_1.requireStringConfig)(components, 'DCL_ESTATE_REGISTRY_ADDRESS');
66
+ return (0, config_1.readStringConfig)(components, 'DCL_ESTATE_REGISTRY_ADDRESS');
67
67
  }
68
68
  exports.getEstateRegistry = getEstateRegistry;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@dcl/sdk-commands",
3
3
  "description": "",
4
- "version": "7.1.7-4743900895.commit-dea19db",
4
+ "version": "7.1.7-4745039397.commit-a6aff2b",
5
5
  "author": "Decentraland",
6
6
  "bin": {
7
7
  "sdk-commands": "./dist/index.js"
8
8
  },
9
9
  "dependencies": {
10
10
  "@dcl/hashing": "1.1.3",
11
- "@dcl/inspector": "7.1.7-4743900895.commit-dea19db",
11
+ "@dcl/inspector": "7.1.7-4745039397.commit-a6aff2b",
12
12
  "@dcl/linker-dapp": "0.7.0",
13
13
  "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
14
14
  "@dcl/protocol": "1.0.0-4671230683.commit-a8d74c3",
@@ -60,5 +60,5 @@
60
60
  "displayName": "SDK",
61
61
  "tsconfig": "./tsconfig.json"
62
62
  },
63
- "commit": "dea19dbb7b318b555669d973af0a37bf3692f313"
63
+ "commit": "a6aff2b8a125015195c818a99a26c9ddea6ac692"
64
64
  }