@taqueria/plugin-octez-client 0.64.1 → 0.64.3
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/client.ts +7 -42
- package/common.ts +22 -4
- package/index.js +15 -52
- package/index.js.map +1 -1
- package/index.mjs +20 -59
- package/index.mjs.map +1 -1
- package/package.json +2 -2
- package/simulate.ts +3 -12
- package/typecheck.ts +2 -13
package/client.ts
CHANGED
|
@@ -1,51 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ClientOpts as Opts,
|
|
3
|
-
|
|
4
|
-
const getArbitraryClientCmd = async (
|
|
5
|
-
parsedArgs: Opts,
|
|
6
|
-
userArgs: string,
|
|
7
|
-
): Promise<[string, Record<string, string>]> => {
|
|
8
|
-
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
9
|
-
if (!projectDir) throw `No project directory provided`;
|
|
10
|
-
const arch = await getArch();
|
|
11
|
-
const flextesaImage = getClientDockerImage();
|
|
12
|
-
const binary = 'docker';
|
|
13
|
-
const baseArgs = [
|
|
14
|
-
'run',
|
|
15
|
-
'--rm',
|
|
16
|
-
'-v',
|
|
17
|
-
`${projectDir}:/project`,
|
|
18
|
-
'-w',
|
|
19
|
-
'/project',
|
|
20
|
-
'--platform',
|
|
21
|
-
arch,
|
|
22
|
-
flextesaImage,
|
|
23
|
-
'octez-client',
|
|
24
|
-
];
|
|
25
|
-
const processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\-') ? arg.substring(1) : arg).filter(arg =>
|
|
26
|
-
arg
|
|
27
|
-
);
|
|
28
|
-
const args = baseArgs.concat(processedUserArgs);
|
|
29
|
-
const envVars = {};
|
|
30
|
-
return [
|
|
31
|
-
[binary, ...args].join(' '),
|
|
32
|
-
envVars,
|
|
33
|
-
];
|
|
34
|
-
};
|
|
1
|
+
import { sendAsyncErr, sendRes } from '@taqueria/node-sdk';
|
|
2
|
+
import { ClientOpts as Opts, execOctezClient } from './common';
|
|
35
3
|
|
|
36
4
|
const runArbitraryClientCmd = (parsedArgs: Opts, cmd: string): Promise<string> =>
|
|
37
|
-
|
|
38
|
-
.then((
|
|
39
|
-
.then(code =>
|
|
40
|
-
code !== null && code === 0
|
|
41
|
-
? `Command "${cmd}" ran successfully by octez-client`
|
|
42
|
-
: `Command "${cmd}" failed. Please check your command`
|
|
43
|
-
)
|
|
5
|
+
execOctezClient(cmd, parsedArgs.projectDir)
|
|
6
|
+
.then(() => `Command "${cmd}" ran successfully by octez-client`)
|
|
44
7
|
.catch(err => sendAsyncErr(`An internal error has occurred: ${err.message}`));
|
|
45
8
|
|
|
46
9
|
const client = (parsedArgs: Opts): Promise<void> => {
|
|
47
10
|
const args = parsedArgs.command;
|
|
48
|
-
return runArbitraryClientCmd(parsedArgs, args)
|
|
11
|
+
return runArbitraryClientCmd(parsedArgs, args)
|
|
12
|
+
.then(sendRes)
|
|
13
|
+
.catch(err => sendAsyncErr(err, false));
|
|
49
14
|
};
|
|
50
15
|
|
|
51
16
|
export default client;
|
package/common.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getArchSync, getDockerImage, ProxyTaskArgs, RequestArgs } from '@taqueria/node-sdk';
|
|
1
|
+
import { execCmd, getArch, getArchSync, getDockerImage, ProxyTaskArgs, RequestArgs } from '@taqueria/node-sdk';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
|
|
4
4
|
// Should point to the latest stable version, so it needs to be updated as part of our release process.
|
|
5
|
-
const getFlextesaImage = (_arch: 'linux/arm64/v8' | 'linux/amd64'): string => 'tezos/tezos:octez-
|
|
5
|
+
const getFlextesaImage = (_arch: 'linux/arm64/v8' | 'linux/amd64'): string => 'tezos/tezos:octez-v21.0';
|
|
6
6
|
|
|
7
7
|
const OCTEZ_CLIENT_IMAGE_ENV_VAR = 'TAQ_OCTEZ_CLIENT_IMAGE';
|
|
8
8
|
|
|
@@ -32,8 +32,7 @@ export type IntersectionOpts = ClientOpts & TypeCheckOpts & TypeCheckAllOpts & S
|
|
|
32
32
|
type UnionOpts = ClientOpts | TypeCheckOpts | TypeCheckAllOpts | SimulateOpts;
|
|
33
33
|
|
|
34
34
|
// Need to talk to ECAD Labs about how to suppress warnings
|
|
35
|
-
|
|
36
|
-
const ENDPOINT = process.env['TAQ_TEZOS_CLIENT_RPC'] ?? 'https://ghostnet.smartpy.io';
|
|
35
|
+
const ENDPOINT = process.env['TAQ_TEZOS_CLIENT_RPC'] ?? 'https://rpc.tzbeta.net';
|
|
37
36
|
export const GLOBAL_OPTIONS = `--endpoint ${ENDPOINT}`;
|
|
38
37
|
|
|
39
38
|
export const trimTezosClientMenuIfPresent = (msg: string): string => {
|
|
@@ -53,3 +52,22 @@ export const getCheckFileExistenceCommand = async (parsedArgs: UnionOpts, source
|
|
|
53
52
|
const cmd = `${baseCmd} ${inputFile}`;
|
|
54
53
|
return cmd;
|
|
55
54
|
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Executes an octez-client command in a Docker container
|
|
58
|
+
* @param args The octez-client command arguments
|
|
59
|
+
* @param projectDir The project directory
|
|
60
|
+
* @returns Promise with the command execution result
|
|
61
|
+
*/
|
|
62
|
+
export const execOctezClient = async (args: string, projectDir?: string) => {
|
|
63
|
+
const actualProjectDir = projectDir ?? process.env.PROJECT_DIR;
|
|
64
|
+
if (!actualProjectDir) throw `No project directory provided`;
|
|
65
|
+
|
|
66
|
+
const arch = await getArch();
|
|
67
|
+
const flextesaImage = getClientDockerImage();
|
|
68
|
+
const baseCmd =
|
|
69
|
+
`docker run --rm --entrypoint octez-client -v \"${actualProjectDir}\":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
70
|
+
const cmd = `${baseCmd} ${GLOBAL_OPTIONS} ${args}`;
|
|
71
|
+
|
|
72
|
+
return await execCmd(cmd, stderr => stderr.replace(/.*Disclaimer:[\s\S]*?\n\n/gs, '').trim());
|
|
73
|
+
};
|
package/index.js
CHANGED
|
@@ -34,10 +34,10 @@ var import_node_sdk2 = require("@taqueria/node-sdk");
|
|
|
34
34
|
// common.ts
|
|
35
35
|
var import_node_sdk = require("@taqueria/node-sdk");
|
|
36
36
|
var import_path = require("path");
|
|
37
|
-
var getFlextesaImage = (_arch) => "tezos/tezos:octez-
|
|
37
|
+
var getFlextesaImage = (_arch) => "tezos/tezos:octez-v21.0";
|
|
38
38
|
var OCTEZ_CLIENT_IMAGE_ENV_VAR = "TAQ_OCTEZ_CLIENT_IMAGE";
|
|
39
39
|
var getClientDockerImage = () => (0, import_node_sdk.getDockerImage)(getFlextesaImage((0, import_node_sdk.getArchSync)()), OCTEZ_CLIENT_IMAGE_ENV_VAR);
|
|
40
|
-
var ENDPOINT = process.env["TAQ_TEZOS_CLIENT_RPC"] ?? "https://
|
|
40
|
+
var ENDPOINT = process.env["TAQ_TEZOS_CLIENT_RPC"] ?? "https://rpc.tzbeta.net";
|
|
41
41
|
var GLOBAL_OPTIONS = `--endpoint ${ENDPOINT}`;
|
|
42
42
|
var trimTezosClientMenuIfPresent = (msg) => {
|
|
43
43
|
return msg.replace(/Usage:(.|\n)+/, "");
|
|
@@ -52,39 +52,18 @@ var getCheckFileExistenceCommand = async (parsedArgs, sourceFile) => {
|
|
|
52
52
|
const cmd = `${baseCmd} ${inputFile}`;
|
|
53
53
|
return cmd;
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
if (!projectDir) throw `No project directory provided`;
|
|
60
|
-
const arch = await (0, import_node_sdk2.getArch)();
|
|
55
|
+
var execOctezClient = async (args, projectDir) => {
|
|
56
|
+
const actualProjectDir = projectDir ?? process.env.PROJECT_DIR;
|
|
57
|
+
if (!actualProjectDir) throw `No project directory provided`;
|
|
58
|
+
const arch = await (0, import_node_sdk.getArch)();
|
|
61
59
|
const flextesaImage = getClientDockerImage();
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
"--rm",
|
|
66
|
-
"-v",
|
|
67
|
-
`${projectDir}:/project`,
|
|
68
|
-
"-w",
|
|
69
|
-
"/project",
|
|
70
|
-
"--platform",
|
|
71
|
-
arch,
|
|
72
|
-
flextesaImage,
|
|
73
|
-
"octez-client"
|
|
74
|
-
];
|
|
75
|
-
const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter(
|
|
76
|
-
(arg) => arg
|
|
77
|
-
);
|
|
78
|
-
const args = baseArgs.concat(processedUserArgs);
|
|
79
|
-
const envVars = {};
|
|
80
|
-
return [
|
|
81
|
-
[binary, ...args].join(" "),
|
|
82
|
-
envVars
|
|
83
|
-
];
|
|
60
|
+
const baseCmd = `docker run --rm --entrypoint octez-client -v "${actualProjectDir}":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
61
|
+
const cmd = `${baseCmd} ${GLOBAL_OPTIONS} ${args}`;
|
|
62
|
+
return await (0, import_node_sdk.execCmd)(cmd, (stderr) => stderr.replace(/.*Disclaimer:[\s\S]*?\n\n/gs, "").trim());
|
|
84
63
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
).catch((err) => (0, import_node_sdk2.sendAsyncErr)(`An internal error has occurred: ${err.message}`));
|
|
64
|
+
|
|
65
|
+
// client.ts
|
|
66
|
+
var runArbitraryClientCmd = (parsedArgs, cmd) => execOctezClient(cmd, parsedArgs.projectDir).then(() => `Command "${cmd}" ran successfully by octez-client`).catch((err) => (0, import_node_sdk2.sendAsyncErr)(`An internal error has occurred: ${err.message}`));
|
|
88
67
|
var client = (parsedArgs) => {
|
|
89
68
|
const args = parsedArgs.command;
|
|
90
69
|
return runArbitraryClientCmd(parsedArgs, args).then(import_node_sdk2.sendRes).catch((err) => (0, import_node_sdk2.sendAsyncErr)(err, false));
|
|
@@ -102,8 +81,6 @@ var getDefaultStorageFilename = (contractName) => {
|
|
|
102
81
|
};
|
|
103
82
|
var getSimulateCmd = async (parsedArgs, sourceFile) => {
|
|
104
83
|
var _a;
|
|
105
|
-
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
106
|
-
if (!projectDir) throw `No project directory provided`;
|
|
107
84
|
const storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(sourceFile);
|
|
108
85
|
const storage = (_a = await (0, import_node_sdk3.getContractContent)(parsedArgs, storageFilename)) == null ? void 0 : _a.trim();
|
|
109
86
|
if (storage === void 0) {
|
|
@@ -118,13 +95,9 @@ You can also manually pass a storage file to the simulate task using the --stora
|
|
|
118
95
|
}
|
|
119
96
|
const paramFilename = parsedArgs.param;
|
|
120
97
|
const param = (await (0, import_node_sdk3.getParameter)(parsedArgs, paramFilename)).trim();
|
|
121
|
-
const arch = await (0, import_node_sdk3.getArch)();
|
|
122
|
-
const flextesaImage = getClientDockerImage();
|
|
123
|
-
const baseCmd = `docker run --rm -v "${projectDir}":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
124
98
|
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
125
99
|
const entrypoint = parsedArgs.entrypoint ? `--entrypoint ${parsedArgs.entrypoint}` : "";
|
|
126
|
-
|
|
127
|
-
return cmd;
|
|
100
|
+
return `run script ${inputFile} on storage '${storage}' and input '${param}' ${entrypoint}`;
|
|
128
101
|
};
|
|
129
102
|
var simulateContract = (parsedArgs, sourceFile) => getCheckFileExistenceCommand(parsedArgs, sourceFile).then(import_node_sdk3.execCmd).catch(
|
|
130
103
|
(_) => Promise.reject(
|
|
@@ -160,7 +133,7 @@ ${stderr}`);
|
|
|
160
133
|
var retrySimulateCmd = (parsedArgs, sourceFile, retryCount) => {
|
|
161
134
|
const max_retries = 3;
|
|
162
135
|
const relay_delay_ms = 1e3;
|
|
163
|
-
return getSimulateCmd(parsedArgs, sourceFile).then(
|
|
136
|
+
return getSimulateCmd(parsedArgs, sourceFile).then((cmd) => execOctezClient(cmd, parsedArgs.projectDir)).catch((err) => {
|
|
164
137
|
if (retryCount < max_retries && err.stderr.includes("503 Service Temporarily")) {
|
|
165
138
|
const delay = relay_delay_ms * Math.pow(2, retryCount);
|
|
166
139
|
return new Promise((resolve) => setTimeout(resolve, delay)).then(() => retrySimulateCmd(parsedArgs, sourceFile, retryCount + 1));
|
|
@@ -179,18 +152,8 @@ var simulate_default = simulate;
|
|
|
179
152
|
|
|
180
153
|
// typecheck.ts
|
|
181
154
|
var import_node_sdk4 = require("@taqueria/node-sdk");
|
|
182
|
-
var getTypecheckCmd = async (parsedArgs, sourceFile) => {
|
|
183
|
-
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
184
|
-
if (!projectDir) throw `No project directory provided`;
|
|
185
|
-
const arch = await (0, import_node_sdk4.getArch)();
|
|
186
|
-
const flextesaImage = getClientDockerImage();
|
|
187
|
-
const baseCmd = `docker run --rm -v "${projectDir}":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
188
|
-
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
189
|
-
const cmd = `${baseCmd} octez-client ${GLOBAL_OPTIONS} typecheck script ${inputFile}`;
|
|
190
|
-
return cmd;
|
|
191
|
-
};
|
|
192
155
|
var typecheckContract = (parsedArgs, sourceFile) => getCheckFileExistenceCommand(parsedArgs, sourceFile).then(import_node_sdk4.execCmd).then(
|
|
193
|
-
() =>
|
|
156
|
+
() => execOctezClient(`typecheck script ${getInputFilename(parsedArgs, sourceFile)}`, parsedArgs.projectDir).then(({ stderr }) => {
|
|
194
157
|
if (stderr.length > 0) (0, import_node_sdk4.sendWarn)(stderr);
|
|
195
158
|
return {
|
|
196
159
|
contract: sourceFile,
|
package/index.js.map
CHANGED
|
@@ -1 +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 => 'tezos/tezos:octez-v20.2';\n\nconst OCTEZ_CLIENT_IMAGE_ENV_VAR = 'TAQ_OCTEZ_CLIENT_IMAGE';\n\nexport const getClientDockerImage = (): string =>\n\tgetDockerImage(getFlextesaImage(getArchSync()), OCTEZ_CLIENT_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\n// Need to talk to ECAD Labs about how to suppress warnings\n// https://github.com/TezosTaqueria/taqueria/actions/runs/10102868947/job/27961869044\nconst ENDPOINT = process.env['TAQ_TEZOS_CLIENT_RPC'] ?? 'https://ghostnet.smartpy.io';\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} --entrypoint /bin/ls ${getClientDockerImage()}`;\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\tjoinPaths,\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.catch(_ =>\n\t\t\tPromise.reject(\n\t\t\t\tnew Error(`${joinPaths(parsedArgs.config.artifactsDir ?? 'artifacts', sourceFile)} does not exist`),\n\t\t\t)\n\t\t)\n\t\t.then(() =>\n\t\t\tretrySimulateCmd(parsedArgs, sourceFile, 0)\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 retrySimulateCmd = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tretryCount: number,\n): Promise<{ stdout: string; stderr: string }> => {\n\tconst max_retries = 3;\n\tconst relay_delay_ms = 1000;\n\treturn getSimulateCmd(parsedArgs, sourceFile)\n\t\t.then(execCmd)\n\t\t.catch(err => {\n\t\t\tif (retryCount < max_retries && err.stderr.includes('503 Service Temporarily')) {\n\t\t\t\tconst delay = relay_delay_ms * Math.pow(2, retryCount);\n\t\t\t\treturn new Promise(resolve => setTimeout(resolve, delay))\n\t\t\t\t\t.then(() => retrySimulateCmd(parsedArgs, sourceFile, retryCount + 1));\n\t\t\t} else {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t});\n};\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,IAAAA,mBAAoD;;;ACApD,IAAAC,mBAAwD;;;ACAxD,IAAAC,mBAAyD;;;ACAzD,sBAAwE;AACxE,kBAAqB;AAGrB,IAAM,mBAAmB,CAAC,UAAoD;AAE9E,IAAM,6BAA6B;AAE5B,IAAM,uBAAuB,UACnC,gCAAe,qBAAiB,6BAAY,CAAC,GAAG,0BAA0B;AA0B3E,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,mBACjD,kBAAK,YAAY,KAAK,OAAO,gBAAgB,aAAa,UAAU;AAE9D,IAAM,+BAA+B,OAAO,YAAuB,eAAwC;AACjH,QAAM,aAAa,QAAQ,IAAI,eAAe,WAAW;AACzD,MAAI,CAAC,WAAY,OAAM;AACvB,QAAM,WAAO,6BAAY;AACzB,QAAM,UACL,uBAAwB,UAAU,qCAAsC,IAAI,yBAAyB,qBAAqB,CAAC;AAC5H,QAAM,YAAY,iBAAiB,YAAY,UAAU;AACzD,QAAM,MAAM,GAAG,OAAO,IAAI,SAAS;AACnC,SAAO;AACR;;;ADnDA,IAAM,wBAAwB,OAC7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QACX,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,IAAI;AAAA,MACd,aAAa;AAAA,MACb,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,+BAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,KAAK;AAAA,MACf,aAAa;AAAA,MACb,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,QACD,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,QACD,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,+BAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,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":["import_node_sdk","import_node_sdk","import_node_sdk","cmd","import_node_sdk","import_path","import_node_sdk","import_node_sdk","import_path","glob"]}
|
|
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 { sendAsyncErr, sendRes } from '@taqueria/node-sdk';\nimport { ClientOpts as Opts, execOctezClient } from './common';\n\nconst runArbitraryClientCmd = (parsedArgs: Opts, cmd: string): Promise<string> =>\n\texecOctezClient(cmd, parsedArgs.projectDir)\n\t\t.then(() => `Command \"${cmd}\" ran successfully by octez-client`)\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)\n\t\t.then(sendRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n};\n\nexport default client;\n","import { execCmd, getArch, 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 => 'tezos/tezos:octez-v21.0';\n\nconst OCTEZ_CLIENT_IMAGE_ENV_VAR = 'TAQ_OCTEZ_CLIENT_IMAGE';\n\nexport const getClientDockerImage = (): string =>\n\tgetDockerImage(getFlextesaImage(getArchSync()), OCTEZ_CLIENT_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\n// Need to talk to ECAD Labs about how to suppress warnings\nconst ENDPOINT = process.env['TAQ_TEZOS_CLIENT_RPC'] ?? 'https://rpc.tzbeta.net';\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} --entrypoint /bin/ls ${getClientDockerImage()}`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst cmd = `${baseCmd} ${inputFile}`;\n\treturn cmd;\n};\n\n/**\n * Executes an octez-client command in a Docker container\n * @param args The octez-client command arguments\n * @param projectDir The project directory\n * @returns Promise with the command execution result\n */\nexport const execOctezClient = async (args: string, projectDir?: string) => {\n\tconst actualProjectDir = projectDir ?? process.env.PROJECT_DIR;\n\tif (!actualProjectDir) throw `No project directory provided`;\n\n\tconst arch = await getArch();\n\tconst flextesaImage = getClientDockerImage();\n\tconst baseCmd =\n\t\t`docker run --rm --entrypoint octez-client -v \\\"${actualProjectDir}\\\":/project -w /project --platform ${arch} ${flextesaImage}`;\n\tconst cmd = `${baseCmd} ${GLOBAL_OPTIONS} ${args}`;\n\n\treturn await execCmd(cmd, stderr => stderr.replace(/.*Disclaimer:[\\s\\S]*?\\n\\n/gs, '').trim());\n};\n","import {\n\taddTzExtensionIfMissing,\n\texecCmd,\n\tgetArch,\n\tgetContractContent,\n\tgetParameter,\n\tjoinPaths,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { basename, extname } from 'path';\nimport {\n\texecOctezClient,\n\tgetCheckFileExistenceCommand,\n\tgetInputFilename,\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 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 inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst entrypoint = parsedArgs.entrypoint ? `--entrypoint ${parsedArgs.entrypoint}` : '';\n\n\treturn `run script ${inputFile} on storage '${storage}' and input '${param}' ${entrypoint}`;\n};\n\nconst simulateContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetCheckFileExistenceCommand(parsedArgs, sourceFile)\n\t\t.then(execCmd)\n\t\t.catch(_ =>\n\t\t\tPromise.reject(\n\t\t\t\tnew Error(`${joinPaths(parsedArgs.config.artifactsDir ?? 'artifacts', sourceFile)} does not exist`),\n\t\t\t)\n\t\t)\n\t\t.then(() =>\n\t\t\tretrySimulateCmd(parsedArgs, sourceFile, 0)\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 retrySimulateCmd = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tretryCount: number,\n): Promise<{ stdout: string; stderr: string }> => {\n\tconst max_retries = 3;\n\tconst relay_delay_ms = 1000;\n\treturn getSimulateCmd(parsedArgs, sourceFile)\n\t\t.then(cmd => execOctezClient(cmd, parsedArgs.projectDir))\n\t\t.catch(err => {\n\t\t\tif (retryCount < max_retries && err.stderr.includes('503 Service Temporarily')) {\n\t\t\t\tconst delay = relay_delay_ms * Math.pow(2, retryCount);\n\t\t\t\treturn new Promise(resolve => setTimeout(resolve, delay))\n\t\t\t\t\t.then(() => retrySimulateCmd(parsedArgs, sourceFile, retryCount + 1));\n\t\t\t} else {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t});\n};\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\texecOctezClient,\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\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\texecOctezClient(`typecheck script ${getInputFilename(parsedArgs, sourceFile)}`, parsedArgs.projectDir)\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,IAAAA,mBAAoD;;;ACApD,IAAAC,mBAAwD;;;ACAxD,IAAAC,mBAAsC;;;ACAtC,sBAA0F;AAC1F,kBAAqB;AAGrB,IAAM,mBAAmB,CAAC,UAAoD;AAE9E,IAAM,6BAA6B;AAE5B,I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,UACb,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,KAAK;AAAA,MACf,aAAa;AAAA,MACb,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,QACD,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,QACD,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aACC;AAAA,UACD,UAAU;AAAA,QACX,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,+BAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,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":["import_node_sdk","import_node_sdk","import_node_sdk","import_node_sdk","import_path","import_node_sdk","import_node_sdk","import_path","glob"]}
|
package/index.mjs
CHANGED
|
@@ -5,15 +5,15 @@ import { Option, Plugin, PositionalArg, Task } from "@taqueria/node-sdk";
|
|
|
5
5
|
import { sendAsyncErr as sendAsyncErr5, sendAsyncRes } from "@taqueria/node-sdk";
|
|
6
6
|
|
|
7
7
|
// client.ts
|
|
8
|
-
import {
|
|
8
|
+
import { sendAsyncErr, sendRes } from "@taqueria/node-sdk";
|
|
9
9
|
|
|
10
10
|
// common.ts
|
|
11
|
-
import { getArchSync, getDockerImage } from "@taqueria/node-sdk";
|
|
11
|
+
import { execCmd, getArch, getArchSync, getDockerImage } from "@taqueria/node-sdk";
|
|
12
12
|
import { join } from "path";
|
|
13
|
-
var getFlextesaImage = (_arch) => "tezos/tezos:octez-
|
|
13
|
+
var getFlextesaImage = (_arch) => "tezos/tezos:octez-v21.0";
|
|
14
14
|
var OCTEZ_CLIENT_IMAGE_ENV_VAR = "TAQ_OCTEZ_CLIENT_IMAGE";
|
|
15
15
|
var getClientDockerImage = () => getDockerImage(getFlextesaImage(getArchSync()), OCTEZ_CLIENT_IMAGE_ENV_VAR);
|
|
16
|
-
var ENDPOINT = process.env["TAQ_TEZOS_CLIENT_RPC"] ?? "https://
|
|
16
|
+
var ENDPOINT = process.env["TAQ_TEZOS_CLIENT_RPC"] ?? "https://rpc.tzbeta.net";
|
|
17
17
|
var GLOBAL_OPTIONS = `--endpoint ${ENDPOINT}`;
|
|
18
18
|
var trimTezosClientMenuIfPresent = (msg) => {
|
|
19
19
|
return msg.replace(/Usage:(.|\n)+/, "");
|
|
@@ -28,39 +28,18 @@ var getCheckFileExistenceCommand = async (parsedArgs, sourceFile) => {
|
|
|
28
28
|
const cmd = `${baseCmd} ${inputFile}`;
|
|
29
29
|
return cmd;
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
35
|
-
if (!projectDir) throw `No project directory provided`;
|
|
31
|
+
var execOctezClient = async (args, projectDir) => {
|
|
32
|
+
const actualProjectDir = projectDir ?? process.env.PROJECT_DIR;
|
|
33
|
+
if (!actualProjectDir) throw `No project directory provided`;
|
|
36
34
|
const arch = await getArch();
|
|
37
35
|
const flextesaImage = getClientDockerImage();
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
"--rm",
|
|
42
|
-
"-v",
|
|
43
|
-
`${projectDir}:/project`,
|
|
44
|
-
"-w",
|
|
45
|
-
"/project",
|
|
46
|
-
"--platform",
|
|
47
|
-
arch,
|
|
48
|
-
flextesaImage,
|
|
49
|
-
"octez-client"
|
|
50
|
-
];
|
|
51
|
-
const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter(
|
|
52
|
-
(arg) => arg
|
|
53
|
-
);
|
|
54
|
-
const args = baseArgs.concat(processedUserArgs);
|
|
55
|
-
const envVars = {};
|
|
56
|
-
return [
|
|
57
|
-
[binary, ...args].join(" "),
|
|
58
|
-
envVars
|
|
59
|
-
];
|
|
36
|
+
const baseCmd = `docker run --rm --entrypoint octez-client -v "${actualProjectDir}":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
37
|
+
const cmd = `${baseCmd} ${GLOBAL_OPTIONS} ${args}`;
|
|
38
|
+
return await execCmd(cmd, (stderr) => stderr.replace(/.*Disclaimer:[\s\S]*?\n\n/gs, "").trim());
|
|
60
39
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
).catch((err) => sendAsyncErr(`An internal error has occurred: ${err.message}`));
|
|
40
|
+
|
|
41
|
+
// client.ts
|
|
42
|
+
var runArbitraryClientCmd = (parsedArgs, cmd) => execOctezClient(cmd, parsedArgs.projectDir).then(() => `Command "${cmd}" ran successfully by octez-client`).catch((err) => sendAsyncErr(`An internal error has occurred: ${err.message}`));
|
|
64
43
|
var client = (parsedArgs) => {
|
|
65
44
|
const args = parsedArgs.command;
|
|
66
45
|
return runArbitraryClientCmd(parsedArgs, args).then(sendRes).catch((err) => sendAsyncErr(err, false));
|
|
@@ -70,8 +49,7 @@ var client_default = client;
|
|
|
70
49
|
// simulate.ts
|
|
71
50
|
import {
|
|
72
51
|
addTzExtensionIfMissing,
|
|
73
|
-
execCmd,
|
|
74
|
-
getArch as getArch2,
|
|
52
|
+
execCmd as execCmd2,
|
|
75
53
|
getContractContent,
|
|
76
54
|
getParameter,
|
|
77
55
|
joinPaths,
|
|
@@ -89,8 +67,6 @@ var getDefaultStorageFilename = (contractName) => {
|
|
|
89
67
|
};
|
|
90
68
|
var getSimulateCmd = async (parsedArgs, sourceFile) => {
|
|
91
69
|
var _a;
|
|
92
|
-
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
93
|
-
if (!projectDir) throw `No project directory provided`;
|
|
94
70
|
const storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(sourceFile);
|
|
95
71
|
const storage = (_a = await getContractContent(parsedArgs, storageFilename)) == null ? void 0 : _a.trim();
|
|
96
72
|
if (storage === void 0) {
|
|
@@ -105,15 +81,11 @@ You can also manually pass a storage file to the simulate task using the --stora
|
|
|
105
81
|
}
|
|
106
82
|
const paramFilename = parsedArgs.param;
|
|
107
83
|
const param = (await getParameter(parsedArgs, paramFilename)).trim();
|
|
108
|
-
const arch = await getArch2();
|
|
109
|
-
const flextesaImage = getClientDockerImage();
|
|
110
|
-
const baseCmd = `docker run --rm -v "${projectDir}":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
111
84
|
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
112
85
|
const entrypoint = parsedArgs.entrypoint ? `--entrypoint ${parsedArgs.entrypoint}` : "";
|
|
113
|
-
|
|
114
|
-
return cmd;
|
|
86
|
+
return `run script ${inputFile} on storage '${storage}' and input '${param}' ${entrypoint}`;
|
|
115
87
|
};
|
|
116
|
-
var simulateContract = (parsedArgs, sourceFile) => getCheckFileExistenceCommand(parsedArgs, sourceFile).then(
|
|
88
|
+
var simulateContract = (parsedArgs, sourceFile) => getCheckFileExistenceCommand(parsedArgs, sourceFile).then(execCmd2).catch(
|
|
117
89
|
(_) => Promise.reject(
|
|
118
90
|
new Error(`${joinPaths(parsedArgs.config.artifactsDir ?? "artifacts", sourceFile)} does not exist`)
|
|
119
91
|
)
|
|
@@ -147,7 +119,7 @@ ${stderr}`);
|
|
|
147
119
|
var retrySimulateCmd = (parsedArgs, sourceFile, retryCount) => {
|
|
148
120
|
const max_retries = 3;
|
|
149
121
|
const relay_delay_ms = 1e3;
|
|
150
|
-
return getSimulateCmd(parsedArgs, sourceFile).then(
|
|
122
|
+
return getSimulateCmd(parsedArgs, sourceFile).then((cmd) => execOctezClient(cmd, parsedArgs.projectDir)).catch((err) => {
|
|
151
123
|
if (retryCount < max_retries && err.stderr.includes("503 Service Temporarily")) {
|
|
152
124
|
const delay = relay_delay_ms * Math.pow(2, retryCount);
|
|
153
125
|
return new Promise((resolve) => setTimeout(resolve, delay)).then(() => retrySimulateCmd(parsedArgs, sourceFile, retryCount + 1));
|
|
@@ -167,25 +139,14 @@ var simulate_default = simulate;
|
|
|
167
139
|
// typecheck.ts
|
|
168
140
|
import {
|
|
169
141
|
addTzExtensionIfMissing as addTzExtensionIfMissing2,
|
|
170
|
-
execCmd as
|
|
171
|
-
getArch as getArch3,
|
|
142
|
+
execCmd as execCmd3,
|
|
172
143
|
sendAsyncErr as sendAsyncErr3,
|
|
173
144
|
sendErr as sendErr2,
|
|
174
145
|
sendJsonRes as sendJsonRes2,
|
|
175
146
|
sendWarn as sendWarn2
|
|
176
147
|
} from "@taqueria/node-sdk";
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
if (!projectDir) throw `No project directory provided`;
|
|
180
|
-
const arch = await getArch3();
|
|
181
|
-
const flextesaImage = getClientDockerImage();
|
|
182
|
-
const baseCmd = `docker run --rm -v "${projectDir}":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
183
|
-
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
184
|
-
const cmd = `${baseCmd} octez-client ${GLOBAL_OPTIONS} typecheck script ${inputFile}`;
|
|
185
|
-
return cmd;
|
|
186
|
-
};
|
|
187
|
-
var typecheckContract = (parsedArgs, sourceFile) => getCheckFileExistenceCommand(parsedArgs, sourceFile).then(execCmd2).then(
|
|
188
|
-
() => getTypecheckCmd(parsedArgs, sourceFile).then(execCmd2).then(({ stderr }) => {
|
|
148
|
+
var typecheckContract = (parsedArgs, sourceFile) => getCheckFileExistenceCommand(parsedArgs, sourceFile).then(execCmd3).then(
|
|
149
|
+
() => execOctezClient(`typecheck script ${getInputFilename(parsedArgs, sourceFile)}`, parsedArgs.projectDir).then(({ stderr }) => {
|
|
189
150
|
if (stderr.length > 0) sendWarn2(stderr);
|
|
190
151
|
return {
|
|
191
152
|
contract: sourceFile,
|
package/index.mjs.map
CHANGED
|
@@ -1 +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 => 'tezos/tezos:octez-v20.2';\n\nconst OCTEZ_CLIENT_IMAGE_ENV_VAR = 'TAQ_OCTEZ_CLIENT_IMAGE';\n\nexport const getClientDockerImage = (): string =>\n\tgetDockerImage(getFlextesaImage(getArchSync()), OCTEZ_CLIENT_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\n// Need to talk to ECAD Labs about how to suppress warnings\n// https://github.com/TezosTaqueria/taqueria/actions/runs/10102868947/job/27961869044\nconst ENDPOINT = process.env['TAQ_TEZOS_CLIENT_RPC'] ?? 'https://ghostnet.smartpy.io';\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} --entrypoint /bin/ls ${getClientDockerImage()}`;\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\tjoinPaths,\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.catch(_ =>\n\t\t\tPromise.reject(\n\t\t\t\tnew Error(`${joinPaths(parsedArgs.config.artifactsDir ?? 'artifacts', sourceFile)} does not exist`),\n\t\t\t)\n\t\t)\n\t\t.then(() =>\n\t\t\tretrySimulateCmd(parsedArgs, sourceFile, 0)\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 retrySimulateCmd = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tretryCount: number,\n): Promise<{ stdout: string; stderr: string }> => {\n\tconst max_retries = 3;\n\tconst relay_delay_ms = 1000;\n\treturn getSimulateCmd(parsedArgs, sourceFile)\n\t\t.then(execCmd)\n\t\t.catch(err => {\n\t\t\tif (retryCount < max_retries && err.stderr.includes('503 Service Temporarily')) {\n\t\t\t\tconst delay = relay_delay_ms * Math.pow(2, retryCount);\n\t\t\t\treturn new Promise(resolve => setTimeout(resolve, delay))\n\t\t\t\t\t.then(() => retrySimulateCmd(parsedArgs, sourceFile, retryCount + 1));\n\t\t\t} else {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t});\n};\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,6BAA6B;AAE5B,IAAM,uBAAuB,MACnC,eAAe,iBAAiB,YAAY,CAAC,GAAG,0BAA0B;AA0B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MACN,SAAS;AAAA,MACT,aAAa;AAAA,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"]}
|
|
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 { sendAsyncErr, sendRes } from '@taqueria/node-sdk';\nimport { ClientOpts as Opts, execOctezClient } from './common';\n\nconst runArbitraryClientCmd = (parsedArgs: Opts, cmd: string): Promise<string> =>\n\texecOctezClient(cmd, parsedArgs.projectDir)\n\t\t.then(() => `Command \"${cmd}\" ran successfully by octez-client`)\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)\n\t\t.then(sendRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n};\n\nexport default client;\n","import { execCmd, getArch, 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 => 'tezos/tezos:octez-v21.0';\n\nconst OCTEZ_CLIENT_IMAGE_ENV_VAR = 'TAQ_OCTEZ_CLIENT_IMAGE';\n\nexport const getClientDockerImage = (): string =>\n\tgetDockerImage(getFlextesaImage(getArchSync()), OCTEZ_CLIENT_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\n// Need to talk to ECAD Labs about how to suppress warnings\nconst ENDPOINT = process.env['TAQ_TEZOS_CLIENT_RPC'] ?? 'https://rpc.tzbeta.net';\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} --entrypoint /bin/ls ${getClientDockerImage()}`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst cmd = `${baseCmd} ${inputFile}`;\n\treturn cmd;\n};\n\n/**\n * Executes an octez-client command in a Docker container\n * @param args The octez-client command arguments\n * @param projectDir The project directory\n * @returns Promise with the command execution result\n */\nexport const execOctezClient = async (args: string, projectDir?: string) => {\n\tconst actualProjectDir = projectDir ?? process.env.PROJECT_DIR;\n\tif (!actualProjectDir) throw `No project directory provided`;\n\n\tconst arch = await getArch();\n\tconst flextesaImage = getClientDockerImage();\n\tconst baseCmd =\n\t\t`docker run --rm --entrypoint octez-client -v \\\"${actualProjectDir}\\\":/project -w /project --platform ${arch} ${flextesaImage}`;\n\tconst cmd = `${baseCmd} ${GLOBAL_OPTIONS} ${args}`;\n\n\treturn await execCmd(cmd, stderr => stderr.replace(/.*Disclaimer:[\\s\\S]*?\\n\\n/gs, '').trim());\n};\n","import {\n\taddTzExtensionIfMissing,\n\texecCmd,\n\tgetArch,\n\tgetContractContent,\n\tgetParameter,\n\tjoinPaths,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { basename, extname } from 'path';\nimport {\n\texecOctezClient,\n\tgetCheckFileExistenceCommand,\n\tgetInputFilename,\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 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 inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst entrypoint = parsedArgs.entrypoint ? `--entrypoint ${parsedArgs.entrypoint}` : '';\n\n\treturn `run script ${inputFile} on storage '${storage}' and input '${param}' ${entrypoint}`;\n};\n\nconst simulateContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetCheckFileExistenceCommand(parsedArgs, sourceFile)\n\t\t.then(execCmd)\n\t\t.catch(_ =>\n\t\t\tPromise.reject(\n\t\t\t\tnew Error(`${joinPaths(parsedArgs.config.artifactsDir ?? 'artifacts', sourceFile)} does not exist`),\n\t\t\t)\n\t\t)\n\t\t.then(() =>\n\t\t\tretrySimulateCmd(parsedArgs, sourceFile, 0)\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 retrySimulateCmd = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tretryCount: number,\n): Promise<{ stdout: string; stderr: string }> => {\n\tconst max_retries = 3;\n\tconst relay_delay_ms = 1000;\n\treturn getSimulateCmd(parsedArgs, sourceFile)\n\t\t.then(cmd => execOctezClient(cmd, parsedArgs.projectDir))\n\t\t.catch(err => {\n\t\t\tif (retryCount < max_retries && err.stderr.includes('503 Service Temporarily')) {\n\t\t\t\tconst delay = relay_delay_ms * Math.pow(2, retryCount);\n\t\t\t\treturn new Promise(resolve => setTimeout(resolve, delay))\n\t\t\t\t\t.then(() => retrySimulateCmd(parsedArgs, sourceFile, retryCount + 1));\n\t\t\t} else {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t});\n};\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\texecOctezClient,\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\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\texecOctezClient(`typecheck script ${getInputFilename(parsedArgs, sourceFile)}`, parsedArgs.projectDir)\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,cAAc,eAAe;;;ACAtC,SAAS,SAAS,SAAS,aAAa,sBAAkD;AAC1F,SAAS,YAAY;AAGrB,IAAM,mBAAmB,CAAC,UAAoD;AAE9E,IAAM,6BAA6B;AAE5B,IAAM,uBAAuB,MACnC,eAAe,iBAAiB,YAAY,CAAC,GAAG,0BAA0B;AAyB3E,IAAM,WAAW,QAAQ,IAAI,sBAAsB,KAAK;AACjD,IAAM,iBAAiB,cAAc,QAAQ;AAE7C,IAAM,+BAA+B,CAAC,QAAwB;AACpE,SAAO,IAAI,QAAQ,iB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A,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,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","execCmd","sendAsyncErr","execCmd","sendAsyncErr","addTzExtensionIfMissing","execCmd","sendAsyncErr","sendErr","sendJsonRes","sendWarn","execCmd","sendWarn","sendErr","addTzExtensionIfMissing","sendJsonRes","sendAsyncErr","sendAsyncErr","sendJsonRes","join","join","sendJsonRes","sendAsyncErr","sendAsyncErr"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-octez-client",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.3",
|
|
4
4
|
"description": "A taqueria plugin for utilizing octez-client",
|
|
5
5
|
"targets": {
|
|
6
6
|
"default": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"homepage": "https://github.com/tezostaqueria/taqueria#readme",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"fast-glob": "^3.3.2",
|
|
40
|
-
"@taqueria/node-sdk": "0.64.
|
|
40
|
+
"@taqueria/node-sdk": "0.64.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"tsup": "^8.0.1",
|
package/simulate.ts
CHANGED
|
@@ -12,10 +12,9 @@ import {
|
|
|
12
12
|
} from '@taqueria/node-sdk';
|
|
13
13
|
import { basename, extname } from 'path';
|
|
14
14
|
import {
|
|
15
|
+
execOctezClient,
|
|
15
16
|
getCheckFileExistenceCommand,
|
|
16
|
-
getClientDockerImage,
|
|
17
17
|
getInputFilename,
|
|
18
|
-
GLOBAL_OPTIONS,
|
|
19
18
|
SimulateOpts as Opts,
|
|
20
19
|
trimTezosClientMenuIfPresent,
|
|
21
20
|
} from './common';
|
|
@@ -39,9 +38,6 @@ const getDefaultStorageFilename = (contractName: string): string => {
|
|
|
39
38
|
};
|
|
40
39
|
|
|
41
40
|
const getSimulateCmd = async (parsedArgs: Opts, sourceFile: string): Promise<string> => {
|
|
42
|
-
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
43
|
-
if (!projectDir) throw `No project directory provided`;
|
|
44
|
-
|
|
45
41
|
const storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(sourceFile);
|
|
46
42
|
const storage = (await getContractContent(parsedArgs, storageFilename))?.trim();
|
|
47
43
|
|
|
@@ -58,15 +54,10 @@ const getSimulateCmd = async (parsedArgs: Opts, sourceFile: string): Promise<str
|
|
|
58
54
|
const paramFilename = parsedArgs.param!;
|
|
59
55
|
const param = (await getParameter(parsedArgs, paramFilename)).trim();
|
|
60
56
|
|
|
61
|
-
const arch = await getArch();
|
|
62
|
-
const flextesaImage = getClientDockerImage();
|
|
63
|
-
const baseCmd = `docker run --rm -v \"${projectDir}\":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
64
57
|
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
65
58
|
const entrypoint = parsedArgs.entrypoint ? `--entrypoint ${parsedArgs.entrypoint}` : '';
|
|
66
59
|
|
|
67
|
-
|
|
68
|
-
`${baseCmd} octez-client ${GLOBAL_OPTIONS} run script ${inputFile} on storage \'${storage}\' and input \'${param}\' ${entrypoint}`;
|
|
69
|
-
return cmd;
|
|
60
|
+
return `run script ${inputFile} on storage '${storage}' and input '${param}' ${entrypoint}`;
|
|
70
61
|
};
|
|
71
62
|
|
|
72
63
|
const simulateContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>
|
|
@@ -113,7 +104,7 @@ const retrySimulateCmd = (
|
|
|
113
104
|
const max_retries = 3;
|
|
114
105
|
const relay_delay_ms = 1000;
|
|
115
106
|
return getSimulateCmd(parsedArgs, sourceFile)
|
|
116
|
-
.then(
|
|
107
|
+
.then(cmd => execOctezClient(cmd, parsedArgs.projectDir))
|
|
117
108
|
.catch(err => {
|
|
118
109
|
if (retryCount < max_retries && err.stderr.includes('503 Service Temporarily')) {
|
|
119
110
|
const delay = relay_delay_ms * Math.pow(2, retryCount);
|
package/typecheck.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
sendWarn,
|
|
9
9
|
} from '@taqueria/node-sdk';
|
|
10
10
|
import {
|
|
11
|
+
execOctezClient,
|
|
11
12
|
getCheckFileExistenceCommand,
|
|
12
13
|
getClientDockerImage,
|
|
13
14
|
getInputFilename,
|
|
@@ -18,23 +19,11 @@ import {
|
|
|
18
19
|
|
|
19
20
|
export type TableRow = { contract: string; result: string };
|
|
20
21
|
|
|
21
|
-
const getTypecheckCmd = async (parsedArgs: Opts, sourceFile: string): Promise<string> => {
|
|
22
|
-
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
23
|
-
if (!projectDir) throw `No project directory provided`;
|
|
24
|
-
const arch = await getArch();
|
|
25
|
-
const flextesaImage = getClientDockerImage();
|
|
26
|
-
const baseCmd = `docker run --rm -v \"${projectDir}\":/project -w /project --platform ${arch} ${flextesaImage}`;
|
|
27
|
-
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
28
|
-
const cmd = `${baseCmd} octez-client ${GLOBAL_OPTIONS} typecheck script ${inputFile}`;
|
|
29
|
-
return cmd;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
22
|
export const typecheckContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>
|
|
33
23
|
getCheckFileExistenceCommand(parsedArgs, sourceFile)
|
|
34
24
|
.then(execCmd)
|
|
35
25
|
.then(() =>
|
|
36
|
-
|
|
37
|
-
.then(execCmd)
|
|
26
|
+
execOctezClient(`typecheck script ${getInputFilename(parsedArgs, sourceFile)}`, parsedArgs.projectDir)
|
|
38
27
|
.then(({ stderr }) => {
|
|
39
28
|
if (stderr.length > 0) sendWarn(stderr);
|
|
40
29
|
return {
|