@taqueria/plugin-octez-client 0.39.24

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/index.mjs ADDED
@@ -0,0 +1,332 @@
1
+ // index.ts
2
+ import { Option, Plugin, PositionalArg, Task } from "@taqueria/node-sdk";
3
+
4
+ // main.ts
5
+ import { sendAsyncErr as sendAsyncErr5, sendAsyncRes } from "@taqueria/node-sdk";
6
+
7
+ // client.ts
8
+ import { getArch, sendAsyncErr, sendRes, spawnCmd } from "@taqueria/node-sdk";
9
+
10
+ // common.ts
11
+ import { getArchSync, getDockerImage } from "@taqueria/node-sdk";
12
+ import { join } from "path";
13
+ var getFlextesaImage = (_arch) => "oxheadalpha/flextesa:20230915";
14
+ var FLEXTESA_IMAGE_ENV_VAR = "TAQ_FLEXTESA_IMAGE";
15
+ var getClientDockerImage = () => getDockerImage(getFlextesaImage(getArchSync()), FLEXTESA_IMAGE_ENV_VAR);
16
+ var ENDPOINT = process.env["TAQ_TEZOS_CLIENT_RPC"] ?? "https://rpc.ghostnet.teztnets.xyz";
17
+ var GLOBAL_OPTIONS = `--endpoint ${ENDPOINT}`;
18
+ var trimTezosClientMenuIfPresent = (msg) => {
19
+ return msg.replace(/Usage:(.|\n)+/, "");
20
+ };
21
+ var getInputFilename = (opts, sourceFile) => join("/project", opts.config.artifactsDir ?? "artifacts", sourceFile);
22
+ var getCheckFileExistenceCommand = async (parsedArgs, sourceFile) => {
23
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
24
+ if (!projectDir)
25
+ throw `No project directory provided`;
26
+ const arch = getArchSync();
27
+ const baseCmd = `docker run --rm -v "${projectDir}":/project -w /project --platform ${arch} ${getClientDockerImage()} ls`;
28
+ const inputFile = getInputFilename(parsedArgs, sourceFile);
29
+ const cmd = `${baseCmd} ${inputFile}`;
30
+ return cmd;
31
+ };
32
+
33
+ // client.ts
34
+ var getArbitraryClientCmd = async (parsedArgs, userArgs) => {
35
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
36
+ if (!projectDir)
37
+ throw `No project directory provided`;
38
+ const arch = await getArch();
39
+ const flextesaImage = getClientDockerImage();
40
+ const binary = "docker";
41
+ const baseArgs = [
42
+ "run",
43
+ "--rm",
44
+ "-v",
45
+ `${projectDir}:/project`,
46
+ "-w",
47
+ "/project",
48
+ "--platform",
49
+ arch,
50
+ flextesaImage,
51
+ "octez-client"
52
+ ];
53
+ const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter(
54
+ (arg) => arg
55
+ );
56
+ const args = baseArgs.concat(processedUserArgs);
57
+ const envVars = {};
58
+ return [
59
+ [binary, ...args].join(" "),
60
+ envVars
61
+ ];
62
+ };
63
+ var runArbitraryClientCmd = (parsedArgs, cmd) => getArbitraryClientCmd(parsedArgs, cmd).then(([cmd2, envVars]) => spawnCmd(cmd2, envVars)).then(
64
+ (code) => code !== null && code === 0 ? `Command "${cmd}" ran successfully by octez-client` : `Command "${cmd}" failed. Please check your command`
65
+ ).catch((err) => sendAsyncErr(`An internal error has occurred: ${err.message}`));
66
+ var client = (parsedArgs) => {
67
+ const args = parsedArgs.command;
68
+ return runArbitraryClientCmd(parsedArgs, args).then(sendRes).catch((err) => sendAsyncErr(err, false));
69
+ };
70
+ var client_default = client;
71
+
72
+ // simulate.ts
73
+ import {
74
+ addTzExtensionIfMissing,
75
+ execCmd,
76
+ getArch as getArch2,
77
+ getContractContent,
78
+ getParameter,
79
+ sendAsyncErr as sendAsyncErr2,
80
+ sendErr,
81
+ sendJsonRes,
82
+ sendWarn
83
+ } from "@taqueria/node-sdk";
84
+ import { basename, extname } from "path";
85
+ var getDefaultStorageFilename = (contractName) => {
86
+ const baseFilename = basename(contractName, extname(contractName));
87
+ const extFilename = extname(contractName);
88
+ const defaultStorage = `${baseFilename}.default_storage${extFilename}`;
89
+ return defaultStorage;
90
+ };
91
+ var getSimulateCmd = async (parsedArgs, sourceFile) => {
92
+ var _a;
93
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
94
+ if (!projectDir)
95
+ throw `No project directory provided`;
96
+ const storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(sourceFile);
97
+ const storage = (_a = await getContractContent(parsedArgs, storageFilename)) == null ? void 0 : _a.trim();
98
+ if (storage === void 0) {
99
+ return Promise.reject(
100
+ new Error(
101
+ `\u274C No initial storage file was found for ${sourceFile}
102
+ Storage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name "${getDefaultStorageFilename(sourceFile)}" in the artifacts directory
103
+ You can also manually pass a storage file to the simulate task using the --storage STORAGE_FILE_NAME option
104
+ `
105
+ )
106
+ );
107
+ }
108
+ const paramFilename = parsedArgs.param;
109
+ const param = (await getParameter(parsedArgs, paramFilename)).trim();
110
+ const arch = await getArch2();
111
+ const flextesaImage = getClientDockerImage();
112
+ const baseCmd = `docker run --rm -v "${projectDir}":/project -w /project --platform ${arch} ${flextesaImage}`;
113
+ const inputFile = getInputFilename(parsedArgs, sourceFile);
114
+ const entrypoint = parsedArgs.entrypoint ? `--entrypoint ${parsedArgs.entrypoint}` : "";
115
+ const cmd = `${baseCmd} octez-client ${GLOBAL_OPTIONS} run script ${inputFile} on storage '${storage}' and input '${param}' ${entrypoint}`;
116
+ return cmd;
117
+ };
118
+ var simulateContract = (parsedArgs, sourceFile) => getCheckFileExistenceCommand(parsedArgs, sourceFile).then(execCmd).then(
119
+ () => getSimulateCmd(parsedArgs, sourceFile).then(execCmd).then(({ stdout, stderr }) => {
120
+ if (stderr.length > 0)
121
+ sendWarn(`
122
+ ${stderr}`);
123
+ return {
124
+ contract: sourceFile,
125
+ result: stdout
126
+ };
127
+ }).catch((err) => {
128
+ sendErr(`
129
+ === For ${sourceFile} ===`);
130
+ const msg = trimTezosClientMenuIfPresent(err.message);
131
+ sendErr(msg.replace(/Command failed.+?\n/, ""));
132
+ return {
133
+ contract: sourceFile,
134
+ result: "Invalid"
135
+ };
136
+ })
137
+ ).catch((err) => {
138
+ sendErr(`
139
+ === For ${sourceFile} ===`);
140
+ sendErr(err.message.replace(/Command failed.+?\n/, ""));
141
+ return {
142
+ contract: sourceFile,
143
+ result: "N/A"
144
+ };
145
+ });
146
+ var simulate = (parsedArgs) => {
147
+ const sourceFile = addTzExtensionIfMissing(parsedArgs.sourceFile);
148
+ return simulateContract(parsedArgs, sourceFile).then((result) => [result]).then(sendJsonRes).catch(
149
+ (err) => sendAsyncErr2(err, false)
150
+ );
151
+ };
152
+ var simulate_default = simulate;
153
+
154
+ // typecheck.ts
155
+ import {
156
+ addTzExtensionIfMissing as addTzExtensionIfMissing2,
157
+ execCmd as execCmd2,
158
+ getArch as getArch3,
159
+ sendAsyncErr as sendAsyncErr3,
160
+ sendErr as sendErr2,
161
+ sendJsonRes as sendJsonRes2,
162
+ sendWarn as sendWarn2
163
+ } from "@taqueria/node-sdk";
164
+ var getTypecheckCmd = async (parsedArgs, sourceFile) => {
165
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
166
+ if (!projectDir)
167
+ throw `No project directory provided`;
168
+ const arch = await getArch3();
169
+ const flextesaImage = getClientDockerImage();
170
+ const baseCmd = `docker run --rm -v "${projectDir}":/project -w /project --platform ${arch} ${flextesaImage}`;
171
+ const inputFile = getInputFilename(parsedArgs, sourceFile);
172
+ const cmd = `${baseCmd} octez-client ${GLOBAL_OPTIONS} typecheck script ${inputFile}`;
173
+ return cmd;
174
+ };
175
+ var typecheckContract = (parsedArgs, sourceFile) => getCheckFileExistenceCommand(parsedArgs, sourceFile).then(execCmd2).then(
176
+ () => getTypecheckCmd(parsedArgs, sourceFile).then(execCmd2).then(({ stderr }) => {
177
+ if (stderr.length > 0)
178
+ sendWarn2(stderr);
179
+ return {
180
+ contract: sourceFile,
181
+ result: "Valid"
182
+ };
183
+ }).catch((err) => {
184
+ sendErr2(`
185
+ === For ${sourceFile} ===`);
186
+ const msg = trimTezosClientMenuIfPresent(err.message);
187
+ sendErr2(msg.replace(/Command failed.+?\n/, ""));
188
+ return {
189
+ contract: sourceFile,
190
+ result: "Invalid"
191
+ };
192
+ })
193
+ ).catch((err) => {
194
+ sendErr2(`
195
+ === For ${sourceFile} ===`);
196
+ sendErr2(err.message.replace(/Command failed.+?\n/, ""));
197
+ return {
198
+ contract: sourceFile,
199
+ result: "N/A"
200
+ };
201
+ });
202
+ var typecheck = (parsedArgs) => {
203
+ const sourceFile = addTzExtensionIfMissing2(parsedArgs.sourceFile);
204
+ return typecheckContract(parsedArgs, sourceFile).then((result) => [result]).then(sendJsonRes2).catch(
205
+ (err) => sendAsyncErr3(err, false)
206
+ );
207
+ };
208
+ var typecheck_default = typecheck;
209
+
210
+ // typecheckAll.ts
211
+ import { getArtifactsDir, isContractFile, sendAsyncErr as sendAsyncErr4, sendJsonRes as sendJsonRes3 } from "@taqueria/node-sdk";
212
+ import glob from "fast-glob";
213
+ import { join as join2 } from "path";
214
+ var compileAll = async (parsedArgs) => {
215
+ let p = [];
216
+ const contractFilenames = await glob(
217
+ ["**/*.tz"],
218
+ { cwd: join2(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs)), absolute: false }
219
+ );
220
+ for (const filename of contractFilenames) {
221
+ if (isContractFile(filename))
222
+ p.push(typecheckContract(parsedArgs, filename));
223
+ }
224
+ return Promise.all(p).then(sendJsonRes3).catch((err) => sendAsyncErr4(err, false));
225
+ };
226
+ var typecheckAll_default = compileAll;
227
+
228
+ // main.ts
229
+ var main = (parsedArgs) => {
230
+ const unsafeOpts = parsedArgs;
231
+ switch (unsafeOpts.task) {
232
+ case "client":
233
+ return client_default(unsafeOpts);
234
+ case "typecheck":
235
+ return typecheck_default(unsafeOpts);
236
+ case "typecheck-all":
237
+ return typecheckAll_default(unsafeOpts);
238
+ case "simulate":
239
+ return simulate_default(unsafeOpts);
240
+ case "get-image":
241
+ return sendAsyncRes(getClientDockerImage());
242
+ default:
243
+ return sendAsyncErr5(`${unsafeOpts.task} is not an understood task by the Tezos-client plugin`);
244
+ }
245
+ };
246
+ var main_default = main;
247
+
248
+ // index.ts
249
+ Plugin.create((i18n) => ({
250
+ alias: "tezos-client",
251
+ schema: "1.0",
252
+ version: "0.1",
253
+ tasks: [
254
+ Task.create({
255
+ task: "client",
256
+ command: "client",
257
+ description: "This task allows you to run arbitrary octez-client native commands. Note that they might not benefit from the abstractions provided by Taqueria",
258
+ options: [
259
+ Option.create({
260
+ shortFlag: "c",
261
+ flag: "command",
262
+ type: "string",
263
+ description: "The command to be passed to the underlying octez-client binary, wrapped in quotes",
264
+ required: true
265
+ })
266
+ ],
267
+ handler: "proxy",
268
+ encoding: "none"
269
+ }),
270
+ Task.create({
271
+ task: "typecheck",
272
+ command: "typecheck <sourceFile>",
273
+ aliases: ["tc"],
274
+ description: "Typecheck a Michelson contract",
275
+ handler: "proxy",
276
+ positionals: [
277
+ PositionalArg.create({
278
+ placeholder: "sourceFile",
279
+ description: "The name of the Michelson contract you wish to typecheck"
280
+ })
281
+ ],
282
+ encoding: "json"
283
+ }),
284
+ Task.create({
285
+ task: "typecheck-all",
286
+ command: "typecheck-all",
287
+ description: "Typecheck all Michelson contracts in the artifacts directory",
288
+ handler: "proxy",
289
+ encoding: "json"
290
+ }),
291
+ Task.create({
292
+ task: "simulate",
293
+ command: "simulate <sourceFile>",
294
+ aliases: ["sim"],
295
+ description: "Run a Michelson contract as a simulation",
296
+ options: [
297
+ Option.create({
298
+ flag: "storage",
299
+ description: "Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract",
300
+ required: false
301
+ }),
302
+ Option.create({
303
+ flag: "param",
304
+ description: "Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract",
305
+ required: true
306
+ }),
307
+ Option.create({
308
+ flag: "entrypoint",
309
+ description: "You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))",
310
+ required: false
311
+ })
312
+ ],
313
+ handler: "proxy",
314
+ positionals: [
315
+ PositionalArg.create({
316
+ placeholder: "sourceFile",
317
+ description: "The name of the Michelson contract you wish to simulate"
318
+ })
319
+ ],
320
+ encoding: "json"
321
+ }),
322
+ Task.create({
323
+ task: "get-image",
324
+ command: "get-image",
325
+ description: "Gets the name of the image to be used",
326
+ handler: "proxy",
327
+ hidden: true
328
+ })
329
+ ],
330
+ proxy: main_default
331
+ }), process.argv);
332
+ //# sourceMappingURL=index.mjs.map
package/index.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts","main.ts","client.ts","common.ts","simulate.ts","typecheck.ts","typecheckAll.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(i18n => ({\n\talias: 'tezos-client',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'client',\n\t\t\tcommand: 'client',\n\t\t\tdescription:\n\t\t\t\t'This task allows you to run arbitrary octez-client native commands. Note that they might not benefit from the abstractions provided by Taqueria',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 'c',\n\t\t\t\t\tflag: 'command',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The command to be passed to the underlying octez-client binary, wrapped in quotes',\n\t\t\t\t\trequired: true,\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'typecheck',\n\t\t\tcommand: 'typecheck <sourceFile>',\n\t\t\taliases: ['tc'],\n\t\t\tdescription: 'Typecheck a Michelson contract',\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'sourceFile',\n\t\t\t\t\tdescription: 'The name of the Michelson contract you wish to typecheck',\n\t\t\t\t}),\n\t\t\t],\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'typecheck-all',\n\t\t\tcommand: 'typecheck-all',\n\t\t\tdescription: 'Typecheck all Michelson contracts in the artifacts directory',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'simulate',\n\t\t\tcommand: 'simulate <sourceFile>',\n\t\t\taliases: ['sim'],\n\t\t\tdescription: 'Run a Michelson contract as a simulation',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'storage',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'param',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract',\n\t\t\t\t\trequired: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'entrypoint',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'sourceFile',\n\t\t\t\t\tdescription: 'The name of the Michelson contract you wish to simulate',\n\t\t\t\t}),\n\t\t\t],\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'get-image',\n\t\t\tcommand: 'get-image',\n\t\t\tdescription: 'Gets the name of the image to be used',\n\t\t\thandler: 'proxy',\n\t\t\thidden: true,\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport client from './client';\nimport { getClientDockerImage, IntersectionOpts as Opts } from './common';\nimport simulate from './simulate';\nimport typecheck from './typecheck';\nimport typecheckAll from './typecheckAll';\n\nconst main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeOpts = parsedArgs as unknown as Opts;\n\tswitch (unsafeOpts.task) {\n\t\tcase 'client':\n\t\t\treturn client(unsafeOpts);\n\t\tcase 'typecheck':\n\t\t\treturn typecheck(unsafeOpts);\n\t\tcase 'typecheck-all':\n\t\t\treturn typecheckAll(unsafeOpts);\n\t\tcase 'simulate':\n\t\t\treturn simulate(unsafeOpts);\n\t\tcase 'get-image':\n\t\t\treturn sendAsyncRes(getClientDockerImage());\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeOpts.task} is not an understood task by the Tezos-client plugin`);\n\t}\n};\n\nexport default main;\n","import { getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';\nimport { ClientOpts as Opts, getClientDockerImage } from './common';\n\nconst getArbitraryClientCmd = async (\n\tparsedArgs: Opts,\n\tuserArgs: string,\n): Promise<[string, Record<string, string>]> => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst arch = await getArch();\n\tconst flextesaImage = getClientDockerImage();\n\tconst binary = 'docker';\n\tconst baseArgs = [\n\t\t'run',\n\t\t'--rm',\n\t\t'-v',\n\t\t`${projectDir}:/project`,\n\t\t'-w',\n\t\t'/project',\n\t\t'--platform',\n\t\tarch,\n\t\tflextesaImage,\n\t\t'octez-client',\n\t];\n\tconst processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\\\-') ? arg.substring(1) : arg).filter(arg =>\n\t\targ\n\t);\n\tconst args = baseArgs.concat(processedUserArgs);\n\tconst envVars = {};\n\treturn [\n\t\t[binary, ...args].join(' '),\n\t\tenvVars,\n\t];\n};\n\nconst runArbitraryClientCmd = (parsedArgs: Opts, cmd: string): Promise<string> =>\n\tgetArbitraryClientCmd(parsedArgs, cmd)\n\t\t.then(([cmd, envVars]) => spawnCmd(cmd, envVars))\n\t\t.then(code =>\n\t\t\tcode !== null && code === 0\n\t\t\t\t? `Command \"${cmd}\" ran successfully by octez-client`\n\t\t\t\t: `Command \"${cmd}\" failed. Please check your command`\n\t\t)\n\t\t.catch(err => sendAsyncErr(`An internal error has occurred: ${err.message}`));\n\nconst client = (parsedArgs: Opts): Promise<void> => {\n\tconst args = parsedArgs.command;\n\treturn runArbitraryClientCmd(parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default client;\n","import { getArchSync, getDockerImage, ProxyTaskArgs, RequestArgs } from '@taqueria/node-sdk';\nimport { join } from 'path';\n\n// Should point to the latest stable version, so it needs to be updated as part of our release process.\nconst getFlextesaImage = (_arch: 'linux/arm64/v8' | 'linux/amd64'): string => 'oxheadalpha/flextesa:20230915';\n\nconst FLEXTESA_IMAGE_ENV_VAR = 'TAQ_FLEXTESA_IMAGE';\n\nexport const getClientDockerImage = (): string =>\n\tgetDockerImage(getFlextesaImage(getArchSync()), FLEXTESA_IMAGE_ENV_VAR);\n\nexport interface ClientOpts extends ProxyTaskArgs.t {\n\tcommand: string;\n}\n\nexport interface TypeCheckOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n}\n\nexport interface TypeCheckAllOpts extends ProxyTaskArgs.t {\n}\n\nexport interface SimulateOpts extends ProxyTaskArgs.t {\n\tsourceFile?: string;\n\tstorage?: string;\n\tparam?: string;\n\tentrypoint?: string;\n}\n\nexport type IntersectionOpts = ClientOpts & TypeCheckOpts & TypeCheckAllOpts & SimulateOpts;\n\ntype UnionOpts = ClientOpts | TypeCheckOpts | TypeCheckAllOpts | SimulateOpts;\n\nconst ENDPOINT = process.env['TAQ_TEZOS_CLIENT_RPC'] ?? 'https://rpc.ghostnet.teztnets.xyz';\nexport const GLOBAL_OPTIONS = `--endpoint ${ENDPOINT}`;\n\nexport const trimTezosClientMenuIfPresent = (msg: string): string => {\n\treturn msg.replace(/Usage:(.|\\n)+/, '');\n};\n\nexport const getInputFilename = (opts: UnionOpts, sourceFile: string) =>\n\tjoin('/project', opts.config.artifactsDir ?? 'artifacts', sourceFile);\n\nexport const getCheckFileExistenceCommand = async (parsedArgs: UnionOpts, sourceFile: string): Promise<string> => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst arch = getArchSync();\n\tconst baseCmd =\n\t\t`docker run --rm -v \\\"${projectDir}\\\":/project -w /project --platform ${arch} ${getClientDockerImage()} ls`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst cmd = `${baseCmd} ${inputFile}`;\n\treturn cmd;\n};\n","import {\n\taddTzExtensionIfMissing,\n\texecCmd,\n\tgetArch,\n\tgetContractContent,\n\tgetParameter,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { basename, extname } from 'path';\nimport {\n\tgetCheckFileExistenceCommand,\n\tgetClientDockerImage,\n\tgetInputFilename,\n\tGLOBAL_OPTIONS,\n\tSimulateOpts as Opts,\n\ttrimTezosClientMenuIfPresent,\n} from './common';\n\ntype TableRow = { contract: string; result: string };\n\n// This is needed mostly due to the fact that execCmd() wraps the command in double quotes\nconst preprocessString = (value: string): string => {\n\t// 1. if the string contains escaped double quotes, escape them further\n\tvalue = value.replace(/\\\\\"/g, '\\\\\\\\\\\\\"');\n\t// 2. if the string contains unescaped double quotes, escape them\n\tvalue = value.replace(/(?<!\\\\)\"/g, '\\\\\"');\n\treturn value;\n};\n\nconst getDefaultStorageFilename = (contractName: string): string => {\n\tconst baseFilename = basename(contractName, extname(contractName));\n\tconst extFilename = extname(contractName);\n\tconst defaultStorage = `${baseFilename}.default_storage${extFilename}`;\n\treturn defaultStorage;\n};\n\nconst getSimulateCmd = async (parsedArgs: Opts, sourceFile: string): Promise<string> => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\n\tconst storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(sourceFile);\n\tconst storage = (await getContractContent(parsedArgs, storageFilename))?.trim();\n\n\tif (storage === undefined) {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\n\t\t\t\t`❌ No initial storage file was found for ${sourceFile}\\nStorage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name \"${\n\t\t\t\t\tgetDefaultStorageFilename(sourceFile)\n\t\t\t\t}\" in the artifacts directory\\nYou can also manually pass a storage file to the simulate task using the --storage STORAGE_FILE_NAME option\\n`,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst paramFilename = parsedArgs.param!;\n\tconst param = (await getParameter(parsedArgs, paramFilename)).trim();\n\n\tconst arch = await getArch();\n\tconst flextesaImage = getClientDockerImage();\n\tconst baseCmd = `docker run --rm -v \\\"${projectDir}\\\":/project -w /project --platform ${arch} ${flextesaImage}`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst entrypoint = parsedArgs.entrypoint ? `--entrypoint ${parsedArgs.entrypoint}` : '';\n\n\tconst cmd =\n\t\t`${baseCmd} octez-client ${GLOBAL_OPTIONS} run script ${inputFile} on storage \\'${storage}\\' and input \\'${param}\\' ${entrypoint}`;\n\treturn cmd;\n};\n\nconst simulateContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetCheckFileExistenceCommand(parsedArgs, sourceFile)\n\t\t.then(execCmd)\n\t\t.then(() =>\n\t\t\tgetSimulateCmd(parsedArgs, sourceFile)\n\t\t\t\t.then(execCmd)\n\t\t\t\t.then(({ stdout, stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(`\\n${stderr}`);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\t\tresult: stdout,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\tsendErr(`\\n=== For ${sourceFile} ===`);\n\t\t\t\t\tconst msg: string = trimTezosClientMenuIfPresent(err.message);\n\t\t\t\t\tsendErr(msg.replace(/Command failed.+?\\n/, ''));\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\t\tresult: 'Invalid',\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t)\n\t\t.catch(err => {\n\t\t\tsendErr(`\\n=== For ${sourceFile} ===`);\n\t\t\tsendErr(err.message.replace(/Command failed.+?\\n/, ''));\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tresult: 'N/A',\n\t\t\t};\n\t\t});\n\nconst simulate = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = addTzExtensionIfMissing(parsedArgs.sourceFile!);\n\treturn simulateContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default simulate;\n","import {\n\taddTzExtensionIfMissing,\n\texecCmd,\n\tgetArch,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport {\n\tgetCheckFileExistenceCommand,\n\tgetClientDockerImage,\n\tgetInputFilename,\n\tGLOBAL_OPTIONS,\n\ttrimTezosClientMenuIfPresent,\n\tTypeCheckOpts as Opts,\n} from './common';\n\nexport type TableRow = { contract: string; result: string };\n\nconst getTypecheckCmd = async (parsedArgs: Opts, sourceFile: string): Promise<string> => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst arch = await getArch();\n\tconst flextesaImage = getClientDockerImage();\n\tconst baseCmd = `docker run --rm -v \\\"${projectDir}\\\":/project -w /project --platform ${arch} ${flextesaImage}`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst cmd = `${baseCmd} octez-client ${GLOBAL_OPTIONS} typecheck script ${inputFile}`;\n\treturn cmd;\n};\n\nexport const typecheckContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetCheckFileExistenceCommand(parsedArgs, sourceFile)\n\t\t.then(execCmd)\n\t\t.then(() =>\n\t\t\tgetTypecheckCmd(parsedArgs, sourceFile)\n\t\t\t\t.then(execCmd)\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\t\tresult: 'Valid',\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\tsendErr(`\\n=== For ${sourceFile} ===`);\n\t\t\t\t\tconst msg: string = trimTezosClientMenuIfPresent(err.message);\n\t\t\t\t\tsendErr(msg.replace(/Command failed.+?\\n/, ''));\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\t\tresult: 'Invalid',\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t)\n\t\t.catch(err => {\n\t\t\tsendErr(`\\n=== For ${sourceFile} ===`);\n\t\t\tsendErr(err.message.replace(/Command failed.+?\\n/, ''));\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tresult: 'N/A',\n\t\t\t};\n\t\t});\n\nconst typecheck = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = addTzExtensionIfMissing(parsedArgs.sourceFile);\n\treturn typecheckContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default typecheck;\n","import { getArtifactsDir, isContractFile, sendAsyncErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { TypeCheckAllOpts as Opts, TypeCheckOpts } from './common';\nimport { TableRow, typecheckContract } from './typecheck';\n\nconst compileAll = async (parsedArgs: Opts): Promise<void> => {\n\tlet p: Promise<TableRow>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.tz'],\n\t\t{ cwd: join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs)), absolute: false },\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (isContractFile(filename)) p.push(typecheckContract(parsedArgs as TypeCheckOpts, filename));\n\t}\n\n\treturn Promise.all(p).then(sendJsonRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default compileAll;\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,eAAe,YAAY;;;ACApD,SAAsB,gBAAAA,eAAc,oBAAoB;;;ACAxD,SAAS,SAAS,cAAc,SAAS,gBAAgB;;;ACAzD,SAAS,aAAa,sBAAkD;AACxE,SAAS,YAAY;AAGrB,IAAM,mBAAmB,CAAC,UAAoD;AAE9E,IAAM,yBAAyB;AAExB,IAAM,uBAAuB,MACnC,eAAe,iBAAiB,YAAY,CAAC,GAAG,sBAAsB;AAwBvE,IAAM,WAAW,QAAQ,IAAI,sBAAsB,KAAK;AACjD,IAAM,iBAAiB,cAAc,QAAQ;AAE7C,IAAM,+BAA+B,CAAC,QAAwB;AACpE,SAAO,IAAI,QAAQ,iBAAiB,EAAE;AACvC;AAEO,IAAM,mBAAmB,CAAC,MAAiB,eACjD,KAAK,YAAY,KAAK,OAAO,gBAAgB,aAAa,UAAU;AAE9D,IAAM,+BAA+B,OAAO,YAAuB,eAAwC;AACjH,QAAM,aAAa,QAAQ,IAAI,eAAe,WAAW;AACzD,MAAI,CAAC;AAAY,UAAM;AACvB,QAAM,OAAO,YAAY;AACzB,QAAM,UACL,uBAAwB,UAAU,qCAAsC,IAAI,IAAI,qBAAqB,CAAC;AACvG,QAAM,YAAY,iBAAiB,YAAY,UAAU;AACzD,QAAM,MAAM,GAAG,OAAO,IAAI,SAAS;AACnC,SAAO;AACR;;;ADjDA,IAAM,wBAAwB,OAC7B,YACA,aAC+C;AAC/C,QAAM,aAAa,QAAQ,IAAI,eAAe,WAAW;AACzD,MAAI,CAAC;AAAY,UAAM;AACvB,QAAM,OAAO,MAAM,QAAQ;AAC3B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AAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,KAAK;AAAA,MACf,aAAa;AAAA,MACb,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,QACD,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,QACD,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,cAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACX,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,QAAQ;AAAA,IACT,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["sendAsyncErr","cmd","getArch","sendAsyncErr","getArch","sendAsyncErr","addTzExtensionIfMissing","execCmd","getArch","sendAsyncErr","sendErr","sendJsonRes","sendWarn","getArch","execCmd","sendWarn","sendErr","addTzExtensionIfMissing","sendJsonRes","sendAsyncErr","sendAsyncErr","sendJsonRes","join","join","sendJsonRes","sendAsyncErr","sendAsyncErr"]}
package/index.ts ADDED
@@ -0,0 +1,90 @@
1
+ import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';
2
+ import main from './main';
3
+
4
+ Plugin.create(i18n => ({
5
+ alias: 'tezos-client',
6
+ schema: '1.0',
7
+ version: '0.1',
8
+ tasks: [
9
+ Task.create({
10
+ task: 'client',
11
+ command: 'client',
12
+ description:
13
+ 'This task allows you to run arbitrary octez-client native commands. Note that they might not benefit from the abstractions provided by Taqueria',
14
+ options: [
15
+ Option.create({
16
+ shortFlag: 'c',
17
+ flag: 'command',
18
+ type: 'string',
19
+ description: 'The command to be passed to the underlying octez-client binary, wrapped in quotes',
20
+ required: true,
21
+ }),
22
+ ],
23
+ handler: 'proxy',
24
+ encoding: 'none',
25
+ }),
26
+ Task.create({
27
+ task: 'typecheck',
28
+ command: 'typecheck <sourceFile>',
29
+ aliases: ['tc'],
30
+ description: 'Typecheck a Michelson contract',
31
+ handler: 'proxy',
32
+ positionals: [
33
+ PositionalArg.create({
34
+ placeholder: 'sourceFile',
35
+ description: 'The name of the Michelson contract you wish to typecheck',
36
+ }),
37
+ ],
38
+ encoding: 'json',
39
+ }),
40
+ Task.create({
41
+ task: 'typecheck-all',
42
+ command: 'typecheck-all',
43
+ description: 'Typecheck all Michelson contracts in the artifacts directory',
44
+ handler: 'proxy',
45
+ encoding: 'json',
46
+ }),
47
+ Task.create({
48
+ task: 'simulate',
49
+ command: 'simulate <sourceFile>',
50
+ aliases: ['sim'],
51
+ description: 'Run a Michelson contract as a simulation',
52
+ options: [
53
+ Option.create({
54
+ flag: 'storage',
55
+ description:
56
+ 'Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract',
57
+ required: false,
58
+ }),
59
+ Option.create({
60
+ flag: 'param',
61
+ description:
62
+ 'Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract',
63
+ required: true,
64
+ }),
65
+ Option.create({
66
+ flag: 'entrypoint',
67
+ description:
68
+ 'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',
69
+ required: false,
70
+ }),
71
+ ],
72
+ handler: 'proxy',
73
+ positionals: [
74
+ PositionalArg.create({
75
+ placeholder: 'sourceFile',
76
+ description: 'The name of the Michelson contract you wish to simulate',
77
+ }),
78
+ ],
79
+ encoding: 'json',
80
+ }),
81
+ Task.create({
82
+ task: 'get-image',
83
+ command: 'get-image',
84
+ description: 'Gets the name of the image to be used',
85
+ handler: 'proxy',
86
+ hidden: true,
87
+ }),
88
+ ],
89
+ proxy: main,
90
+ }), process.argv);
package/main.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
2
+ import client from './client';
3
+ import { getClientDockerImage, IntersectionOpts as Opts } from './common';
4
+ import simulate from './simulate';
5
+ import typecheck from './typecheck';
6
+ import typecheckAll from './typecheckAll';
7
+
8
+ const main = (parsedArgs: RequestArgs.t): Promise<void> => {
9
+ const unsafeOpts = parsedArgs as unknown as Opts;
10
+ switch (unsafeOpts.task) {
11
+ case 'client':
12
+ return client(unsafeOpts);
13
+ case 'typecheck':
14
+ return typecheck(unsafeOpts);
15
+ case 'typecheck-all':
16
+ return typecheckAll(unsafeOpts);
17
+ case 'simulate':
18
+ return simulate(unsafeOpts);
19
+ case 'get-image':
20
+ return sendAsyncRes(getClientDockerImage());
21
+ default:
22
+ return sendAsyncErr(`${unsafeOpts.task} is not an understood task by the Tezos-client plugin`);
23
+ }
24
+ };
25
+
26
+ export default main;
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@taqueria/plugin-octez-client",
3
+ "version": "0.39.24",
4
+ "description": "A taqueria plugin for utilizing octez-client",
5
+ "targets": {
6
+ "default": {
7
+ "source": "./index.ts",
8
+ "distDir": "./",
9
+ "context": "node",
10
+ "isLibrary": true
11
+ }
12
+ },
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1",
15
+ "build": "npx tsc -noEmit -p ./tsconfig.json && npx tsup",
16
+ "pluginInfo": "npx ts-node index.ts --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}"
17
+ },
18
+ "keywords": [
19
+ "taqueria",
20
+ "tezos",
21
+ "pinnaclelabs",
22
+ "pinnacle-labs",
23
+ "plugin",
24
+ "tezos-client",
25
+ "octez-client",
26
+ "typecheck",
27
+ "simulate"
28
+ ],
29
+ "engines": {
30
+ "node": ">=16"
31
+ },
32
+ "author": "Pinnacle Labs",
33
+ "license": "Apache-2.0",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/pinnacle-labs/taqueria.git",
37
+ "directory": "taqueria-plugin-tezos-client"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/pinnacle-labs/taqueria/issues"
41
+ },
42
+ "homepage": "https://github.com/pinnacle-labs/taqueria#readme",
43
+ "dependencies": {
44
+ "@taqueria/node-sdk": "^0.39.24",
45
+ "fast-glob": "^3.3.1"
46
+ },
47
+ "devDependencies": {
48
+ "tsup": "^7.2.0",
49
+ "typescript": "^5.2.2"
50
+ },
51
+ "tsup": {
52
+ "entry": [
53
+ "index.ts"
54
+ ],
55
+ "sourcemap": true,
56
+ "target": "node16",
57
+ "outDir": "./",
58
+ "dts": true,
59
+ "clean": false,
60
+ "skipNodeModulesBundle": true,
61
+ "platform": "node",
62
+ "format": [
63
+ "esm",
64
+ "cjs"
65
+ ]
66
+ },
67
+ "gitHead": "ff58a2fc06ad233869ad6be574093c8b3b272e2e"
68
+ }
package/simulate.ts ADDED
@@ -0,0 +1,110 @@
1
+ import {
2
+ addTzExtensionIfMissing,
3
+ execCmd,
4
+ getArch,
5
+ getContractContent,
6
+ getParameter,
7
+ sendAsyncErr,
8
+ sendErr,
9
+ sendJsonRes,
10
+ sendWarn,
11
+ } from '@taqueria/node-sdk';
12
+ import { basename, extname } from 'path';
13
+ import {
14
+ getCheckFileExistenceCommand,
15
+ getClientDockerImage,
16
+ getInputFilename,
17
+ GLOBAL_OPTIONS,
18
+ SimulateOpts as Opts,
19
+ trimTezosClientMenuIfPresent,
20
+ } from './common';
21
+
22
+ type TableRow = { contract: string; result: string };
23
+
24
+ // This is needed mostly due to the fact that execCmd() wraps the command in double quotes
25
+ const preprocessString = (value: string): string => {
26
+ // 1. if the string contains escaped double quotes, escape them further
27
+ value = value.replace(/\\"/g, '\\\\\\"');
28
+ // 2. if the string contains unescaped double quotes, escape them
29
+ value = value.replace(/(?<!\\)"/g, '\\"');
30
+ return value;
31
+ };
32
+
33
+ const getDefaultStorageFilename = (contractName: string): string => {
34
+ const baseFilename = basename(contractName, extname(contractName));
35
+ const extFilename = extname(contractName);
36
+ const defaultStorage = `${baseFilename}.default_storage${extFilename}`;
37
+ return defaultStorage;
38
+ };
39
+
40
+ const getSimulateCmd = async (parsedArgs: Opts, sourceFile: string): Promise<string> => {
41
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
42
+ if (!projectDir) throw `No project directory provided`;
43
+
44
+ const storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(sourceFile);
45
+ const storage = (await getContractContent(parsedArgs, storageFilename))?.trim();
46
+
47
+ if (storage === undefined) {
48
+ return Promise.reject(
49
+ new Error(
50
+ `❌ No initial storage file was found for ${sourceFile}\nStorage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name "${
51
+ getDefaultStorageFilename(sourceFile)
52
+ }" in the artifacts directory\nYou can also manually pass a storage file to the simulate task using the --storage STORAGE_FILE_NAME option\n`,
53
+ ),
54
+ );
55
+ }
56
+
57
+ const paramFilename = parsedArgs.param!;
58
+ const param = (await getParameter(parsedArgs, paramFilename)).trim();
59
+
60
+ const arch = await getArch();
61
+ const flextesaImage = getClientDockerImage();
62
+ const baseCmd = `docker run --rm -v \"${projectDir}\":/project -w /project --platform ${arch} ${flextesaImage}`;
63
+ const inputFile = getInputFilename(parsedArgs, sourceFile);
64
+ const entrypoint = parsedArgs.entrypoint ? `--entrypoint ${parsedArgs.entrypoint}` : '';
65
+
66
+ const cmd =
67
+ `${baseCmd} octez-client ${GLOBAL_OPTIONS} run script ${inputFile} on storage \'${storage}\' and input \'${param}\' ${entrypoint}`;
68
+ return cmd;
69
+ };
70
+
71
+ const simulateContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>
72
+ getCheckFileExistenceCommand(parsedArgs, sourceFile)
73
+ .then(execCmd)
74
+ .then(() =>
75
+ getSimulateCmd(parsedArgs, sourceFile)
76
+ .then(execCmd)
77
+ .then(({ stdout, stderr }) => {
78
+ if (stderr.length > 0) sendWarn(`\n${stderr}`);
79
+ return {
80
+ contract: sourceFile,
81
+ result: stdout,
82
+ };
83
+ })
84
+ .catch(err => {
85
+ sendErr(`\n=== For ${sourceFile} ===`);
86
+ const msg: string = trimTezosClientMenuIfPresent(err.message);
87
+ sendErr(msg.replace(/Command failed.+?\n/, ''));
88
+ return {
89
+ contract: sourceFile,
90
+ result: 'Invalid',
91
+ };
92
+ })
93
+ )
94
+ .catch(err => {
95
+ sendErr(`\n=== For ${sourceFile} ===`);
96
+ sendErr(err.message.replace(/Command failed.+?\n/, ''));
97
+ return {
98
+ contract: sourceFile,
99
+ result: 'N/A',
100
+ };
101
+ });
102
+
103
+ const simulate = (parsedArgs: Opts): Promise<void> => {
104
+ const sourceFile = addTzExtensionIfMissing(parsedArgs.sourceFile!);
105
+ return simulateContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>
106
+ sendAsyncErr(err, false)
107
+ );
108
+ };
109
+
110
+ export default simulate;