@taqueria/plugin-ligo 0.37.21 → 0.37.34
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/common.ts +3 -2
- package/compile-all.ts +15 -111
- package/compile.ts +413 -174
- package/createContract.ts +1 -5
- package/index.js +396 -329
- package/index.js.map +1 -1
- package/index.mjs +407 -333
- package/index.mjs.map +1 -1
- package/index.ts +7 -0
- package/ligo.ts +1 -1
- package/ligo_templates.ts +17 -94
- package/package.json +3 -3
- package/postinstall.js +19 -0
package/index.js
CHANGED
|
@@ -28,109 +28,33 @@ var import_promises = require("fs/promises");
|
|
|
28
28
|
// ligo_templates.ts
|
|
29
29
|
var mligo_template = `
|
|
30
30
|
type storage = int
|
|
31
|
-
|
|
32
|
-
type parameter =
|
|
33
|
-
Increment of int
|
|
34
|
-
| Decrement of int
|
|
35
|
-
| Reset
|
|
36
|
-
|
|
37
31
|
type return = operation list * storage
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
let main (action, store : parameter * storage) : return =
|
|
48
|
-
([] : operation list), // No operations
|
|
49
|
-
(match action with
|
|
50
|
-
Increment (n) -> add (store, n)
|
|
51
|
-
| Decrement (n) -> sub (store, n)
|
|
52
|
-
| Reset -> 0)
|
|
53
|
-
`;
|
|
54
|
-
var pascaligo_template = `
|
|
55
|
-
type storage is int
|
|
56
|
-
|
|
57
|
-
type parameter is
|
|
58
|
-
Increment of int
|
|
59
|
-
| Decrement of int
|
|
60
|
-
| Reset
|
|
61
|
-
|
|
62
|
-
type return is list (operation) * storage
|
|
63
|
-
|
|
64
|
-
// Two entrypoints
|
|
65
|
-
|
|
66
|
-
function add (const store : storage; const delta : int) : storage is
|
|
67
|
-
store + delta
|
|
68
|
-
|
|
69
|
-
function sub (const store : storage; const delta : int) : storage is
|
|
70
|
-
store - delta
|
|
71
|
-
|
|
72
|
-
(* Main access point that dispatches to the entrypoints according to
|
|
73
|
-
the smart contract parameter. *)
|
|
74
|
-
|
|
75
|
-
function main (const action : parameter; const store : storage) : return is
|
|
76
|
-
((nil : list (operation)), // No operations
|
|
77
|
-
case action of [
|
|
78
|
-
Increment (n) -> add (store, n)
|
|
79
|
-
| Decrement (n) -> sub (store, n)
|
|
80
|
-
| Reset -> 0
|
|
81
|
-
])
|
|
82
|
-
`;
|
|
83
|
-
var religo_template = `
|
|
84
|
-
type storage = int;
|
|
85
|
-
|
|
86
|
-
type parameter =
|
|
87
|
-
Increment (int)
|
|
88
|
-
| Decrement (int)
|
|
89
|
-
| Reset;
|
|
90
|
-
|
|
91
|
-
type return = (list (operation), storage);
|
|
92
|
-
|
|
93
|
-
// Two entrypoints
|
|
94
|
-
|
|
95
|
-
let add = ((store, delta) : (storage, int)) : storage => store + delta;
|
|
96
|
-
let sub = ((store, delta) : (storage, int)) : storage => store - delta;
|
|
97
|
-
|
|
98
|
-
/* Main access point that dispatches to the entrypoints according to
|
|
99
|
-
the smart contract parameter. */
|
|
100
|
-
|
|
101
|
-
let main = ((action, store) : (parameter, storage)) : return => {
|
|
102
|
-
(([] : list (operation)), // No operations
|
|
103
|
-
(switch (action) {
|
|
104
|
-
| Increment (n) => add ((store, n))
|
|
105
|
-
| Decrement (n) => sub ((store, n))
|
|
106
|
-
| Reset => 0}))
|
|
107
|
-
};
|
|
33
|
+
(* Three entrypoints *)
|
|
34
|
+
[@entry] let increment (delta : int) (store : storage) : return =
|
|
35
|
+
[], store + delta
|
|
36
|
+
[@entry] let decrement (delta : int) (store : storage) : return =
|
|
37
|
+
[], store - delta
|
|
38
|
+
[@entry] let reset (() : unit) (_ : storage) : return =
|
|
39
|
+
[], 0
|
|
108
40
|
`;
|
|
109
41
|
var jsligo_template = `
|
|
110
42
|
type storage = int;
|
|
111
|
-
|
|
112
|
-
type parameter =
|
|
113
|
-
["Increment", int]
|
|
114
|
-
| ["Decrement", int]
|
|
115
|
-
| ["Reset"];
|
|
116
|
-
|
|
117
43
|
type ret = [list<operation>, storage];
|
|
118
44
|
|
|
119
|
-
//
|
|
45
|
+
// Three entrypoints
|
|
120
46
|
|
|
121
|
-
|
|
122
|
-
const
|
|
47
|
+
// @entry
|
|
48
|
+
const increment = (delta : int, store : storage) : ret =>
|
|
49
|
+
[list([]), store + delta];
|
|
123
50
|
|
|
124
|
-
|
|
125
|
-
|
|
51
|
+
// @entry
|
|
52
|
+
const decrement = (delta : int, store : storage) : ret =>
|
|
53
|
+
[list([]), store - delta];
|
|
126
54
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
Increment:(n: int) => add ([store, n]),
|
|
131
|
-
Decrement:(n: int) => sub ([store, n]),
|
|
132
|
-
Reset :() => 0})]
|
|
133
|
-
};
|
|
55
|
+
// @entry
|
|
56
|
+
const reset = (_ : unit, _ : storage) : ret =>
|
|
57
|
+
[list([]), 0];
|
|
134
58
|
`;
|
|
135
59
|
|
|
136
60
|
// createContract.ts
|
|
@@ -139,19 +63,11 @@ var getLigoTemplate = async (contractName, syntax) => {
|
|
|
139
63
|
const ext = matchResult ? matchResult[0].substring(1) : null;
|
|
140
64
|
if (syntax === "mligo")
|
|
141
65
|
return mligo_template;
|
|
142
|
-
if (syntax === "ligo")
|
|
143
|
-
return pascaligo_template;
|
|
144
|
-
if (syntax === "religo")
|
|
145
|
-
return religo_template;
|
|
146
66
|
if (syntax === "jsligo")
|
|
147
67
|
return jsligo_template;
|
|
148
68
|
if (syntax === void 0) {
|
|
149
69
|
if (ext === "mligo")
|
|
150
70
|
return mligo_template;
|
|
151
|
-
if (ext === "ligo")
|
|
152
|
-
return pascaligo_template;
|
|
153
|
-
if (ext === "religo")
|
|
154
|
-
return religo_template;
|
|
155
71
|
if (ext === "jsligo")
|
|
156
72
|
return jsligo_template;
|
|
157
73
|
return (0, import_node_sdk.sendAsyncErr)(
|
|
@@ -176,7 +92,7 @@ var import_node_sdk8 = require("@taqueria/node-sdk");
|
|
|
176
92
|
// common.ts
|
|
177
93
|
var import_node_sdk2 = require("@taqueria/node-sdk");
|
|
178
94
|
var import_path = require("path");
|
|
179
|
-
var LIGO_DEFAULT_IMAGE = "ligolang/ligo:0.
|
|
95
|
+
var LIGO_DEFAULT_IMAGE = "ligolang/ligo:0.71.0";
|
|
180
96
|
var LIGO_IMAGE_ENV_VAR = "TAQ_LIGO_IMAGE";
|
|
181
97
|
var getLigoDockerImage = () => (0, import_node_sdk2.getDockerImage)(LIGO_DEFAULT_IMAGE, LIGO_IMAGE_ENV_VAR);
|
|
182
98
|
var getInputFilenameAbsPath = (parsedArgs, sourceFile) => (0, import_path.join)(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? "contracts", sourceFile);
|
|
@@ -195,17 +111,63 @@ var import_promises2 = require("fs/promises");
|
|
|
195
111
|
var import_path2 = require("path");
|
|
196
112
|
var COMPILE_ERR_MSG = "Not compiled";
|
|
197
113
|
var isStorageKind = (exprKind) => exprKind === "storage" || exprKind === "default_storage";
|
|
198
|
-
var
|
|
114
|
+
var isSupportedLigoSyntax = (sourceFile) => /\.(mligo|jsligo)$/.test(sourceFile);
|
|
115
|
+
var isUnsupportedLigoSyntax = (sourceFile) => /\.(ligo|religo)$/.test(sourceFile);
|
|
116
|
+
var isLIGOFile = (sourceFile) => isSupportedLigoSyntax(sourceFile) || isUnsupportedLigoSyntax(sourceFile);
|
|
199
117
|
var isStorageListFile = (sourceFile) => /.+\.(storageList|storages)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
200
118
|
var isParameterListFile = (sourceFile) => /.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
201
|
-
var
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
119
|
+
var listContractModules = async (parsedArgs, sourceFile) => {
|
|
120
|
+
try {
|
|
121
|
+
await (0, import_node_sdk3.getArch)();
|
|
122
|
+
const cmd = await getListDeclarationsCmd(parsedArgs, sourceFile);
|
|
123
|
+
const { stderr, stdout } = await (0, import_node_sdk3.execCmd)(cmd);
|
|
124
|
+
if (stderr.length > 0)
|
|
125
|
+
return Promise.reject(stderr);
|
|
126
|
+
return JSON.parse(stdout).declarations.reduce(
|
|
127
|
+
(acc, decl) => {
|
|
128
|
+
const srcFile = removeExt((0, import_path2.basename)(sourceFile));
|
|
129
|
+
const syntax = extractExt(sourceFile).replace(".", "");
|
|
130
|
+
if (decl === "main") {
|
|
131
|
+
return [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: "file-main", syntax }];
|
|
132
|
+
} else if (decl === "$main") {
|
|
133
|
+
return [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: "file-entry", syntax }];
|
|
134
|
+
} else if (decl.endsWith(".main")) {
|
|
135
|
+
const moduleName = decl.replace(/\.main$/, "");
|
|
136
|
+
return [...acc, {
|
|
137
|
+
moduleName,
|
|
138
|
+
sourceName: `${sourceFile}/${moduleName}`,
|
|
139
|
+
sourceFile,
|
|
140
|
+
type: "module-main",
|
|
141
|
+
syntax
|
|
142
|
+
}];
|
|
143
|
+
} else if (decl.endsWith(".$main")) {
|
|
144
|
+
const moduleName = decl.replace(/\.\$main$/, "");
|
|
145
|
+
return [...acc, {
|
|
146
|
+
moduleName,
|
|
147
|
+
sourceName: `${sourceFile}/${moduleName}`,
|
|
148
|
+
sourceFile,
|
|
149
|
+
type: "module-entry",
|
|
150
|
+
syntax
|
|
151
|
+
}];
|
|
152
|
+
}
|
|
153
|
+
return acc;
|
|
154
|
+
},
|
|
155
|
+
[]
|
|
156
|
+
);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
emitExternalError(err, sourceFile);
|
|
159
|
+
return [];
|
|
207
160
|
}
|
|
208
|
-
|
|
161
|
+
};
|
|
162
|
+
var getListDeclarationsCmd = async (parsedArgs, sourceFile) => {
|
|
163
|
+
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
164
|
+
if (!projectDir)
|
|
165
|
+
throw new Error(`No project directory provided`);
|
|
166
|
+
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v "${projectDir}":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} info list-declarations`;
|
|
167
|
+
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
168
|
+
const flags = "--display-format json";
|
|
169
|
+
const cmd = `${baseCmd} ${inputFile} ${flags}`;
|
|
170
|
+
return cmd;
|
|
209
171
|
};
|
|
210
172
|
var extractExt = (path) => {
|
|
211
173
|
const matchResult = path.match(/\.(ligo|religo|mligo|jsligo)$/);
|
|
@@ -216,291 +178,396 @@ var removeExt = (path) => {
|
|
|
216
178
|
return path.replace(extRegex, "");
|
|
217
179
|
};
|
|
218
180
|
var isOutputFormatJSON = (parsedArgs) => parsedArgs.json;
|
|
219
|
-
var getOutputContractFilename = (parsedArgs,
|
|
220
|
-
const outputFile = (0, import_path2.basename)(sourceFile, (0, import_path2.extname)(sourceFile));
|
|
181
|
+
var getOutputContractFilename = (parsedArgs, module2) => {
|
|
221
182
|
const ext = isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
|
|
222
|
-
return (0, import_path2.join)((0, import_node_sdk3.getArtifactsDir)(parsedArgs), `${
|
|
183
|
+
return (0, import_path2.join)((0, import_node_sdk3.getArtifactsDir)(parsedArgs), `${module2.moduleName}${ext}`);
|
|
223
184
|
};
|
|
224
|
-
var
|
|
225
|
-
|
|
226
|
-
return isStorageKind(exprKind) ? sourceFile.match(/.+(?=\.(?:storageList|storages)\.(ligo|religo|mligo|jsligo))/).join(".") : sourceFile.match(/.+(?=\.(?:parameterList|parameters)\.(ligo|religo|mligo|jsligo))/).join(".");
|
|
227
|
-
} catch (err) {
|
|
228
|
-
throw new Error(`Something went wrong internally when dealing with filename format: ${err}`);
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
var getOutputExprFilename = (parsedArgs, sourceFile, exprKind, exprName) => {
|
|
232
|
-
const contractName = (0, import_path2.basename)(getContractNameForExpr(sourceFile, exprKind), (0, import_path2.extname)(sourceFile));
|
|
185
|
+
var getOutputExprFilename = (parsedArgs, module2, exprKind, exprName) => {
|
|
186
|
+
const contractName = module2.moduleName;
|
|
233
187
|
const ext = isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
|
|
234
188
|
const outputFile = exprKind === "default_storage" ? `${contractName}.default_storage${ext}` : `${contractName}.${exprKind}.${exprName}${ext}`;
|
|
235
189
|
return (0, import_path2.join)((0, import_node_sdk3.getArtifactsDir)(parsedArgs), `${outputFile}`);
|
|
236
190
|
};
|
|
237
|
-
var getCompileContractCmd = async (parsedArgs, sourceFile) => {
|
|
191
|
+
var getCompileContractCmd = async (parsedArgs, sourceFile, module2) => {
|
|
238
192
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
239
193
|
if (!projectDir)
|
|
240
|
-
throw `No project directory provided
|
|
194
|
+
throw new Error(`No project directory provided`);
|
|
241
195
|
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v "${projectDir}":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;
|
|
242
196
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
243
|
-
const outputFile = `-o ${getOutputContractFilename(parsedArgs,
|
|
197
|
+
const outputFile = `-o ${getOutputContractFilename(parsedArgs, module2)}`;
|
|
244
198
|
const flags = isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}${entryFlag}`;
|
|
199
|
+
const moduleFlag = module2.type.startsWith("file-") ? "" : `-m ${module2.moduleName}`;
|
|
200
|
+
const cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}${moduleFlag}`;
|
|
248
201
|
return cmd;
|
|
249
202
|
};
|
|
250
|
-
var getCompileExprCmd = (parsedArgs, sourceFile, exprKind, exprName) => {
|
|
203
|
+
var getCompileExprCmd = (parsedArgs, sourceFile, module2, exprKind, exprName) => {
|
|
251
204
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
252
205
|
if (!projectDir)
|
|
253
|
-
throw `No project directory provided
|
|
206
|
+
throw new Error(`No project directory provided`);
|
|
254
207
|
const compilerType = isStorageKind(exprKind) ? "storage" : "parameter";
|
|
255
208
|
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v "${projectDir}":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;
|
|
256
209
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
257
|
-
const outputFile = `-o ${getOutputExprFilename(parsedArgs,
|
|
210
|
+
const outputFile = `-o ${getOutputExprFilename(parsedArgs, module2, exprKind, exprName)}`;
|
|
258
211
|
const flags = isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
|
|
259
|
-
const
|
|
212
|
+
const moduleFlag = (() => {
|
|
213
|
+
switch (module2.type) {
|
|
214
|
+
case "file-main":
|
|
215
|
+
case "file-entry":
|
|
216
|
+
return "-m Contract";
|
|
217
|
+
default:
|
|
218
|
+
return `-m Contract.${module2.moduleName}`;
|
|
219
|
+
}
|
|
220
|
+
})();
|
|
221
|
+
const cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile} ${flags} ${moduleFlag}`;
|
|
260
222
|
return cmd;
|
|
261
223
|
};
|
|
262
|
-
var compileContract = async (parsedArgs, sourceFile) => {
|
|
224
|
+
var compileContract = async (parsedArgs, sourceFile, module2) => {
|
|
263
225
|
try {
|
|
264
226
|
await (0, import_node_sdk3.getArch)();
|
|
265
|
-
const cmd = await getCompileContractCmd(parsedArgs, sourceFile);
|
|
227
|
+
const cmd = await getCompileContractCmd(parsedArgs, sourceFile, module2);
|
|
266
228
|
const { stderr } = await (0, import_node_sdk3.execCmd)(cmd);
|
|
267
229
|
if (stderr.length > 0)
|
|
268
230
|
(0, import_node_sdk3.sendWarn)(stderr);
|
|
269
231
|
return {
|
|
270
|
-
|
|
271
|
-
artifact: getOutputContractFilename(parsedArgs,
|
|
232
|
+
source: module2.sourceName,
|
|
233
|
+
artifact: getOutputContractFilename(parsedArgs, module2)
|
|
272
234
|
};
|
|
273
235
|
} catch (err) {
|
|
274
236
|
emitExternalError(err, sourceFile);
|
|
275
237
|
return {
|
|
276
|
-
|
|
238
|
+
source: module2.sourceName,
|
|
277
239
|
artifact: COMPILE_ERR_MSG
|
|
278
240
|
};
|
|
279
241
|
}
|
|
280
242
|
};
|
|
281
|
-
var compileExpr = (parsedArgs, sourceFile,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
243
|
+
var compileExpr = (parsedArgs, sourceFile, module2, exprKind) => (exprName) => {
|
|
244
|
+
return (0, import_node_sdk3.getArch)().then(() => getCompileExprCmd(parsedArgs, sourceFile, module2, exprKind, exprName)).then(import_node_sdk3.execCmd).then(({ stderr }) => {
|
|
245
|
+
if (stderr.length > 0)
|
|
246
|
+
(0, import_node_sdk3.sendWarn)(stderr);
|
|
247
|
+
const artifactName = getOutputExprFilename(parsedArgs, module2, exprKind, exprName);
|
|
248
|
+
return {
|
|
249
|
+
source: module2.sourceName,
|
|
250
|
+
artifact: artifactName
|
|
251
|
+
};
|
|
252
|
+
}).catch((err) => {
|
|
253
|
+
emitExternalError(err, sourceFile);
|
|
254
|
+
return {
|
|
255
|
+
source: module2.sourceName,
|
|
256
|
+
artifact: `${sourceFile} not compiled`
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
};
|
|
296
260
|
var getExprNames = (parsedArgs, sourceFile) => (0, import_promises2.readFile)(getInputFilenameAbsPath(parsedArgs, sourceFile), "utf8").then((data) => data.match(/(?<=\n\s*(let|const)\s+)[a-zA-Z0-9_]+/g) ?? []);
|
|
297
|
-
var compileExprs = (parsedArgs, sourceFile, exprKind) => getExprNames(parsedArgs, sourceFile).then((exprNames) => {
|
|
261
|
+
var compileExprs = (parsedArgs, sourceFile, module2, exprKind) => getExprNames(parsedArgs, sourceFile).then((exprNames) => {
|
|
298
262
|
if (exprNames.length === 0)
|
|
299
263
|
return [];
|
|
300
264
|
const firstExprName = exprNames.slice(0, 1)[0];
|
|
301
265
|
const restExprNames = exprNames.slice(1, exprNames.length);
|
|
302
266
|
const firstExprKind = isStorageKind(exprKind) ? "default_storage" : "parameter";
|
|
303
267
|
const restExprKind = isStorageKind(exprKind) ? "storage" : "parameter";
|
|
304
|
-
const firstExprResult = compileExpr(parsedArgs, sourceFile, firstExprKind)(firstExprName);
|
|
305
|
-
const restExprResults = restExprNames.map(compileExpr(parsedArgs, sourceFile, restExprKind));
|
|
268
|
+
const firstExprResult = compileExpr(parsedArgs, sourceFile, module2, firstExprKind)(firstExprName);
|
|
269
|
+
const restExprResults = restExprNames.map(compileExpr(parsedArgs, sourceFile, module2, restExprKind));
|
|
306
270
|
return Promise.all([firstExprResult].concat(restExprResults));
|
|
307
271
|
}).catch((err) => {
|
|
308
272
|
emitExternalError(err, sourceFile);
|
|
309
273
|
return [{
|
|
310
|
-
|
|
274
|
+
source: module2.sourceName,
|
|
311
275
|
artifact: `No ${isStorageKind(exprKind) ? "storage" : "parameter"} expressions compiled`
|
|
312
276
|
}];
|
|
313
277
|
}).then(
|
|
314
278
|
(results) => results.length > 0 ? results : [{
|
|
315
|
-
|
|
279
|
+
source: module2.sourceName,
|
|
316
280
|
artifact: `No ${isStorageKind(exprKind) ? "storage" : "parameter"} expressions found`
|
|
317
281
|
}]
|
|
318
|
-
)
|
|
319
|
-
var
|
|
320
|
-
const
|
|
321
|
-
const storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);
|
|
322
|
-
return (0, import_promises2.access)(storageListFilename).then(() => {
|
|
323
|
-
(0, import_node_sdk3.sendWarn)(
|
|
324
|
-
`Warning: The naming convention of "<CONTRACT>.storages.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.storageList.<EXTENSION>". Please adjust your storage file names accordingly
|
|
325
|
-
`
|
|
326
|
-
);
|
|
327
|
-
return compileExprs(parsedArgs, storageListFile, "storage");
|
|
328
|
-
});
|
|
329
|
-
};
|
|
330
|
-
var tryLegacyParameterNamingConvention = (parsedArgs, sourceFile) => {
|
|
331
|
-
const parameterListFile = `${removeExt(sourceFile)}.parameters${extractExt(sourceFile)}`;
|
|
332
|
-
const parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);
|
|
333
|
-
return (0, import_promises2.access)(parameterListFilename).then(() => {
|
|
334
|
-
(0, import_node_sdk3.sendWarn)(
|
|
335
|
-
`Warning: The naming convention of "<CONTRACT>.parameters.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.parameterList.<EXTENSION>". Please adjust your parameter file names accordingly
|
|
336
|
-
`
|
|
337
|
-
);
|
|
338
|
-
return compileExprs(parsedArgs, parameterListFile, "parameter");
|
|
339
|
-
});
|
|
340
|
-
};
|
|
341
|
-
var initContentForStorage = (sourceFile) => {
|
|
342
|
-
const linkToContract = `#include "${sourceFile}"
|
|
282
|
+
);
|
|
283
|
+
var initContentForStorage = (module2) => {
|
|
284
|
+
const linkToContract = `#import "${module2.sourceFile}" "Contract"
|
|
343
285
|
|
|
344
286
|
`;
|
|
345
|
-
const instruction = "// Define your initial storage values as a list of LIGO variable definitions
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
287
|
+
const instruction = "// Define your initial storage values as a list of LIGO variable definitions, the first of which will be considered the default value to be used for origination later on\n";
|
|
288
|
+
const syntax = (() => {
|
|
289
|
+
const pair = [module2.syntax, module2.type].join("-");
|
|
290
|
+
switch (pair) {
|
|
291
|
+
case "mligo-file-main":
|
|
292
|
+
return [
|
|
293
|
+
"// When this file was created, the smart contract was defined with a main function that was not within a named module. As such, the examples below are written with that assumption in mind.",
|
|
294
|
+
"",
|
|
295
|
+
"// If your storage is a simple value, you can define it directly",
|
|
296
|
+
"// E.g. let storage = 10",
|
|
297
|
+
"",
|
|
298
|
+
"// For added type-safety, you can reference the type of your storage from the contract",
|
|
299
|
+
"// E.g. let storage : Contract.storage = 10"
|
|
300
|
+
];
|
|
301
|
+
break;
|
|
302
|
+
case "mligo-file-entry":
|
|
303
|
+
return [
|
|
304
|
+
"// When this file was created, the smart contract was defined with an entrypoint using `@entry` that was not within a named module. As such, the examples below are written with that assumption in mind.",
|
|
305
|
+
"",
|
|
306
|
+
"// If your storage is a simple value, you can define it directly",
|
|
307
|
+
"// E.g. let storage = 10",
|
|
308
|
+
"",
|
|
309
|
+
"// For added type-safety, you can reference the type of your storage from the contract",
|
|
310
|
+
"// E.g. let storage : Contract.storage = 10"
|
|
311
|
+
];
|
|
312
|
+
break;
|
|
313
|
+
case "mligo-module-main":
|
|
314
|
+
return [
|
|
315
|
+
"// When this file was created, the smart contract was defined with a main function that was within a named module. As such, the examples below are written with that assumption in mind.",
|
|
316
|
+
"",
|
|
317
|
+
"// If your storage is a simple value, you can define it directly",
|
|
318
|
+
"// E.g. let storage = 10",
|
|
319
|
+
"",
|
|
320
|
+
"// For added type-safety, you can reference the type of your storage from the contract",
|
|
321
|
+
`// E.g. let storage : Contract.${module2.moduleName}.storage = 10`
|
|
322
|
+
];
|
|
323
|
+
break;
|
|
324
|
+
case "mligo-module-entry":
|
|
325
|
+
return [
|
|
326
|
+
"// When this file was created, the smart contract was defined with an entrypoint using `@entry` that was within a named module. As such, the examples below are written with that assumption in mind.",
|
|
327
|
+
"",
|
|
328
|
+
"// If your storage is a simple value, you can define it directly",
|
|
329
|
+
"// E.g. let storage = 10",
|
|
330
|
+
"",
|
|
331
|
+
"// For added type-safety, you can reference the type of your storage from the contract",
|
|
332
|
+
`// E.g. let storage : Contract.${module2.moduleName}.storage = 10`
|
|
333
|
+
];
|
|
334
|
+
break;
|
|
335
|
+
case "jsligo-file-main":
|
|
336
|
+
return [
|
|
337
|
+
"// When this file was created, the smart contract was defined with a main function that was not within a namespace. As such, the examples below are written with that assumption in mind.",
|
|
338
|
+
`// NOTE: The "storage" type should be exported from the contract file (${module2.sourceFile})`,
|
|
339
|
+
"",
|
|
340
|
+
"// If your storage is a simple value, you can define it directly",
|
|
341
|
+
"// E.g. const storage = 10",
|
|
342
|
+
"",
|
|
343
|
+
"// For added type-safety, you can reference the type of your storage from the contract. This assumes that you have exported your `storage` type from the contract file.",
|
|
344
|
+
"// E.g. const storage : Contract.storage = 10"
|
|
345
|
+
];
|
|
346
|
+
break;
|
|
347
|
+
case "jsligo-file-entry":
|
|
348
|
+
return [
|
|
349
|
+
"// When this file was created, the smart contract was defined with an entrypoint using `@entry` that was not within a namespace. As such, the examples below are written with that assumption in mind.",
|
|
350
|
+
"",
|
|
351
|
+
"// If your storage is a simple value, you can define it directly",
|
|
352
|
+
"// E.g. const storage = 10",
|
|
353
|
+
"",
|
|
354
|
+
"// For added type-safety, you can reference the type of your storage from the contract. This assumes that you have exported your `storage` type from the contract file.",
|
|
355
|
+
"// E.g. const storage : Contract.storage = 10"
|
|
356
|
+
];
|
|
357
|
+
break;
|
|
358
|
+
case "jsligo-module-main":
|
|
359
|
+
return [
|
|
360
|
+
"// When this file was created, the smart contract was defined with a main function that was within a namespace. As such, the examples below are written with that assumption in mind.",
|
|
361
|
+
`// NOTE: The "storage" type should be exported from the contract file (${module2.sourceFile})`,
|
|
362
|
+
"",
|
|
363
|
+
"// If your storage is a simple value, you can define it directly",
|
|
364
|
+
"// E.g. const storage = 10",
|
|
365
|
+
"",
|
|
366
|
+
"// For added type-safety, you can reference the type of your storage from the contract. This assumes that you have exported your `storage` type from the contract file.",
|
|
367
|
+
`// E.g. const storage : Contract.${module2.moduleName}.storage = 10`
|
|
368
|
+
];
|
|
369
|
+
break;
|
|
370
|
+
case "jsligo-module-entry":
|
|
371
|
+
return [
|
|
372
|
+
"// When this file was created, the smart contract was defined with an entrypoint using `@entry` that was within a namespace. As such, the examples below are written with that assumption in mind.",
|
|
373
|
+
"",
|
|
374
|
+
"// If your storage is a simple value, you can define it directly",
|
|
375
|
+
"// E.g. const storage = 10",
|
|
376
|
+
"",
|
|
377
|
+
"// For added type-safety, you can reference the type of your storage from the contract. This assumes that you have exported your `storage` type from the contract file.",
|
|
378
|
+
`// E.g. const storage : Contract.${module2.moduleName}.storage = 10`
|
|
379
|
+
];
|
|
380
|
+
break;
|
|
381
|
+
default:
|
|
382
|
+
return [];
|
|
383
|
+
}
|
|
384
|
+
})();
|
|
385
|
+
return linkToContract + instruction + syntax.join("\n");
|
|
357
386
|
};
|
|
358
|
-
var initContentForParameter = (
|
|
359
|
-
const linkToContract = `#
|
|
387
|
+
var initContentForParameter = (module2) => {
|
|
388
|
+
const linkToContract = `#import "${module2.sourceFile}" "Contract"
|
|
360
389
|
|
|
361
390
|
`;
|
|
362
391
|
const instruction = "// Define your parameter values as a list of LIGO variable definitions\n";
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
392
|
+
const syntax = (() => {
|
|
393
|
+
const pair = [module2.syntax, module2.type].join("-");
|
|
394
|
+
switch (pair) {
|
|
395
|
+
case "mligo-file-main":
|
|
396
|
+
return [
|
|
397
|
+
"// When this file was created, the smart contract was defined with a main function that was not within a named module. As such, the examples below are written with that assumption in mind.",
|
|
398
|
+
"",
|
|
399
|
+
"// If your parameter is a simple value, you can define it directly",
|
|
400
|
+
"// E.g. let default_parameter = 10",
|
|
401
|
+
"",
|
|
402
|
+
"// For added type-safety, you can reference the type of your parameter from the contract",
|
|
403
|
+
"// E.g. let default_parameter : Contract.parameter = 10"
|
|
404
|
+
];
|
|
405
|
+
break;
|
|
406
|
+
case "mligo-file-entry":
|
|
407
|
+
return [
|
|
408
|
+
"// When this file was created, the smart contract was defined with an entrypoint using `@entry` that was not within a named module. As such, the examples below are written with that assumption in mind.",
|
|
409
|
+
"",
|
|
410
|
+
"// If your parameter is a simple value, you can define it directly",
|
|
411
|
+
"// E.g. let default_parameter = 10",
|
|
412
|
+
"",
|
|
413
|
+
"// For added type-safety, you can reference the type of your parameter from the contract",
|
|
414
|
+
"// E.g. let default_parameter : parameter_of Contract = 10"
|
|
415
|
+
];
|
|
416
|
+
break;
|
|
417
|
+
case "mligo-module-main":
|
|
418
|
+
return [
|
|
419
|
+
"// When this file was created, the smart contract was defined with a main function that was within a named module. As such, the examples below are written with that assumption in mind.",
|
|
420
|
+
"",
|
|
421
|
+
"// If your parameter is a simple value, you can define it directly",
|
|
422
|
+
"// E.g. let default_parameter = 10",
|
|
423
|
+
"",
|
|
424
|
+
"// For added type-safety, you can reference the type of your parameter from the contract",
|
|
425
|
+
`// E.g. let default_parameter : Contract.${module2.moduleName}.parameter = 10`
|
|
426
|
+
];
|
|
427
|
+
break;
|
|
428
|
+
case "mligo-module-entry":
|
|
429
|
+
return [
|
|
430
|
+
"// When this file was created, the smart contract was defined with an entrypoint using `@entry` that was within a named module. As such, the examples below are written with that assumption in mind.",
|
|
431
|
+
"",
|
|
432
|
+
"// If your parameter is a simple value, you can define it directly",
|
|
433
|
+
"// E.g. let default_parameter = 10",
|
|
434
|
+
"",
|
|
435
|
+
"// For added type-safety, you can reference the type of your parameter from the contract",
|
|
436
|
+
`// E.g. let default_parameter : parameter_of Contract.${module2.moduleName} = 10`
|
|
437
|
+
];
|
|
438
|
+
break;
|
|
439
|
+
case "jsligo-file-main":
|
|
440
|
+
return [
|
|
441
|
+
"// When this file was created, the smart contract was defined with a main function that was not within a namespace. As such, the examples below are written with that assumption in mind.",
|
|
442
|
+
`// NOTE: The "parameter" type should be exported from the contract file (${module2.sourceFile})`,
|
|
443
|
+
"",
|
|
444
|
+
"// If your parameter is a simple value, you can define it directly",
|
|
445
|
+
"// E.g. const default_parameter = 10",
|
|
446
|
+
"",
|
|
447
|
+
"// For added type-safety, you can reference the type of your parameter from the contract",
|
|
448
|
+
"// E.g. const default_parameter : Contract.parameter = 10"
|
|
449
|
+
];
|
|
450
|
+
break;
|
|
451
|
+
case "jsligo-file-entry":
|
|
452
|
+
return [
|
|
453
|
+
"// When this file was created, the smart contract was defined with an entrypoint using `@entry` that was not within a namespace. As such, the examples below are written with that assumption in mind.",
|
|
454
|
+
"",
|
|
455
|
+
"// If your parameter is a simple value, you can define it directly",
|
|
456
|
+
"// E.g. const default_parameter = 10",
|
|
457
|
+
"",
|
|
458
|
+
"// For added type-safety, you can reference the type of your parameter from the contract",
|
|
459
|
+
"// E.g. const default_parameter : parameter_of Contract = 10"
|
|
460
|
+
];
|
|
461
|
+
break;
|
|
462
|
+
case "jsligo-module-main":
|
|
463
|
+
return [
|
|
464
|
+
"// When this file was created, the smart contract was defined with a main function that was within a namespace. As such, the examples below are written with that assumption in mind.",
|
|
465
|
+
`// NOTE: The "parameter" type should be exported from the contract file (${module2.sourceFile})`,
|
|
466
|
+
"",
|
|
467
|
+
"// If your parameter is a simple value, you can define it directly",
|
|
468
|
+
"// E.g. const default_parameter = 10",
|
|
469
|
+
"",
|
|
470
|
+
"// For added type-safety, you can reference the type of your parameter from the contract",
|
|
471
|
+
`// E.g. const default_parameter : Contract.${module2.moduleName}.parameter = 10`
|
|
472
|
+
];
|
|
473
|
+
break;
|
|
474
|
+
case "jsligo-module-entry":
|
|
475
|
+
return [
|
|
476
|
+
"// When this file was created, the smart contract was defined with an entrypoint using `@entry` that was within a namespace. As such, the examples below are written with that assumption in mind.",
|
|
477
|
+
"",
|
|
478
|
+
"// If your parameter is a simple value, you can define it directly",
|
|
479
|
+
"// E.g. const default_parameter = 10",
|
|
480
|
+
"",
|
|
481
|
+
"// For added type-safety, you can reference the type of your parameter from the contract",
|
|
482
|
+
`// E.g. const default_parameter : parameter_of Contract.${module2.moduleName} = 10`
|
|
483
|
+
];
|
|
484
|
+
break;
|
|
485
|
+
default:
|
|
486
|
+
return [];
|
|
487
|
+
}
|
|
488
|
+
})();
|
|
489
|
+
return linkToContract + instruction + syntax.join("\n");
|
|
374
490
|
};
|
|
375
|
-
var compileContractWithStorageAndParameter = async (parsedArgs, sourceFile) => {
|
|
376
|
-
const contractCompileResult = await compileContract(parsedArgs, sourceFile);
|
|
491
|
+
var compileContractWithStorageAndParameter = async (parsedArgs, sourceFile, module2) => {
|
|
492
|
+
const contractCompileResult = await compileContract(parsedArgs, sourceFile, module2);
|
|
377
493
|
if (contractCompileResult.artifact === COMPILE_ERR_MSG)
|
|
378
494
|
return [contractCompileResult];
|
|
379
|
-
const storageListFile = `${
|
|
495
|
+
const storageListFile = `${module2.moduleName}.storageList${extractExt(sourceFile)}`;
|
|
380
496
|
const storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);
|
|
381
|
-
const storageCompileResult = await (0, import_promises2.access)(storageListFilename).then(() => compileExprs(parsedArgs, storageListFile, "storage")).catch(() =>
|
|
497
|
+
const storageCompileResult = await (0, import_promises2.access)(storageListFilename).then(() => compileExprs(parsedArgs, storageListFile, module2, "storage")).catch(() => {
|
|
382
498
|
(0, import_node_sdk3.sendWarn)(
|
|
383
|
-
`Note: storage file associated with "${
|
|
499
|
+
`Note: storage file associated with "${module2.moduleName}" can't be found, so "${storageListFile}" has been created for you. Use this file to define all initial storage values for this contract
|
|
384
500
|
`
|
|
385
501
|
);
|
|
386
|
-
(0, import_promises2.writeFile)(storageListFilename, initContentForStorage(
|
|
502
|
+
return (0, import_promises2.writeFile)(storageListFilename, initContentForStorage(module2), "utf8");
|
|
387
503
|
});
|
|
388
|
-
const parameterListFile = `${
|
|
504
|
+
const parameterListFile = `${module2.moduleName}.parameterList${extractExt(sourceFile)}`;
|
|
389
505
|
const parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);
|
|
390
|
-
const parameterCompileResult = await (0, import_promises2.access)(parameterListFilename).then(() => compileExprs(parsedArgs, parameterListFile, "parameter")).catch(() =>
|
|
506
|
+
const parameterCompileResult = await (0, import_promises2.access)(parameterListFilename).then(() => compileExprs(parsedArgs, parameterListFile, module2, "parameter")).catch(() => {
|
|
391
507
|
(0, import_node_sdk3.sendWarn)(
|
|
392
|
-
`Note: parameter file associated with "${
|
|
508
|
+
`Note: parameter file associated with "${module2.moduleName}" can't be found, so "${parameterListFile}" has been created for you. Use this file to define all parameter values for this contract
|
|
393
509
|
`
|
|
394
510
|
);
|
|
395
|
-
(0, import_promises2.writeFile)(parameterListFilename, initContentForParameter(
|
|
511
|
+
return (0, import_promises2.writeFile)(parameterListFilename, initContentForParameter(module2), "utf8");
|
|
396
512
|
});
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
);
|
|
410
|
-
return [{
|
|
411
|
-
contract: sourceFile,
|
|
412
|
-
artifact: artifactsOutput
|
|
413
|
-
}];
|
|
513
|
+
const storageArtifacts = storageCompileResult ? storageCompileResult.map((res) => res.artifact).join("\n") : "";
|
|
514
|
+
const parameterArtifacts = parameterCompileResult ? parameterCompileResult.map((res) => res.artifact).join("\n") : "";
|
|
515
|
+
const combinedArtifact = [
|
|
516
|
+
contractCompileResult.artifact,
|
|
517
|
+
storageArtifacts,
|
|
518
|
+
parameterArtifacts
|
|
519
|
+
].filter(Boolean).join("\n");
|
|
520
|
+
const combinedRow = {
|
|
521
|
+
source: module2.sourceName,
|
|
522
|
+
artifact: combinedArtifact
|
|
523
|
+
};
|
|
524
|
+
return [combinedRow];
|
|
414
525
|
};
|
|
415
|
-
var compile = (parsedArgs) => {
|
|
526
|
+
var compile = async (parsedArgs) => {
|
|
416
527
|
const sourceFile = parsedArgs.sourceFile;
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
528
|
+
if (!isLIGOFile(sourceFile)) {
|
|
529
|
+
(0, import_node_sdk3.sendErr)(`${sourceFile} is not a LIGO file`);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
if (isStorageListFile(sourceFile) || isParameterListFile(sourceFile)) {
|
|
533
|
+
(0, import_node_sdk3.sendErr)(`Storage and parameter list files are not meant to be compiled directly`);
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
if (isUnsupportedLigoSyntax(sourceFile)) {
|
|
537
|
+
(0, import_node_sdk3.sendErr)(`Unsupported LIGO syntax detected in ${sourceFile}. Note, we only support .jsligo and .mligo files.`);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
try {
|
|
541
|
+
const modules = await listContractModules(parsedArgs, sourceFile);
|
|
542
|
+
if (modules.length === 0) {
|
|
543
|
+
return (0, import_node_sdk3.sendJsonRes)([
|
|
544
|
+
{
|
|
545
|
+
source: sourceFile,
|
|
546
|
+
artifact: `No contract modules found in "${sourceFile}"`
|
|
547
|
+
}
|
|
548
|
+
]);
|
|
549
|
+
}
|
|
550
|
+
let allCompileResults = [];
|
|
551
|
+
for (const module2 of modules) {
|
|
552
|
+
if (parsedArgs.module && parsedArgs.module !== module2.moduleName)
|
|
553
|
+
continue;
|
|
554
|
+
const compileResults = await compileContractWithStorageAndParameter(parsedArgs, sourceFile, module2);
|
|
555
|
+
allCompileResults = allCompileResults.concat(compileResults);
|
|
556
|
+
}
|
|
557
|
+
(0, import_node_sdk3.sendJsonRes)(allCompileResults, { footer: `
|
|
558
|
+
Compiled ${allCompileResults.length} contract(s) in "${sourceFile}"` });
|
|
559
|
+
} catch (err) {
|
|
560
|
+
(0, import_node_sdk3.sendErr)(`Error processing "${sourceFile}": ${err}`);
|
|
428
561
|
}
|
|
429
|
-
return p.then(import_node_sdk3.sendJsonRes).catch((err) => (0, import_node_sdk3.sendErr)(err, false));
|
|
430
562
|
};
|
|
431
563
|
var compile_default = compile;
|
|
432
564
|
|
|
433
565
|
// compile-all.ts
|
|
434
566
|
var import_node_sdk4 = require("@taqueria/node-sdk");
|
|
435
567
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
436
|
-
var import_promises3 = require("fs/promises");
|
|
437
568
|
var import_path3 = require("path");
|
|
438
|
-
var isMainContract = async (parsedArgs, contractFilename) => {
|
|
439
|
-
if (/storageList\.\w{0,2}ligo$/.test(contractFilename))
|
|
440
|
-
return false;
|
|
441
|
-
const fileContent = await (0, import_promises3.readFile)(getInputFilenameAbsPath(parsedArgs, contractFilename), "utf8");
|
|
442
|
-
const entryOrMainFunctionRegex = /@entry|((const|let|function)\s+main)/g;
|
|
443
|
-
return entryOrMainFunctionRegex.test(fileContent);
|
|
444
|
-
};
|
|
445
|
-
var parseIncludes = async (parsedArgs, contractFilename) => {
|
|
446
|
-
const fileContent = await (0, import_promises3.readFile)(getInputFilenameAbsPath(parsedArgs, contractFilename), "utf8");
|
|
447
|
-
const includeRegex = /#include\s+"([^"]+\.m?ligo)"/g;
|
|
448
|
-
let match;
|
|
449
|
-
const includes = [];
|
|
450
|
-
while ((match = includeRegex.exec(fileContent)) !== null) {
|
|
451
|
-
includes.push(match[1]);
|
|
452
|
-
}
|
|
453
|
-
return includes;
|
|
454
|
-
};
|
|
455
|
-
var buildDependencyGraph = async (parsedArgs, contractFilenames) => {
|
|
456
|
-
const graph = /* @__PURE__ */ new Map();
|
|
457
|
-
for (const filename of contractFilenames) {
|
|
458
|
-
const includes = await parseIncludes(parsedArgs, filename);
|
|
459
|
-
graph.set(filename, new Set(includes));
|
|
460
|
-
}
|
|
461
|
-
return graph;
|
|
462
|
-
};
|
|
463
|
-
var visit = (node, graph, visited, stack) => {
|
|
464
|
-
if (stack.has(node))
|
|
465
|
-
return [true, visited];
|
|
466
|
-
if (!visited.has(node)) {
|
|
467
|
-
const newVisited = new Set(visited).add(node);
|
|
468
|
-
const newStack = new Set(stack).add(node);
|
|
469
|
-
const [circular, updatedVisited] = Array.from(graph.get(node) || []).reduce(
|
|
470
|
-
([circularFound, vSet], dependency) => {
|
|
471
|
-
const [result, v] = visit(dependency, graph, vSet, newStack);
|
|
472
|
-
return [circularFound || result, v];
|
|
473
|
-
},
|
|
474
|
-
[false, newVisited]
|
|
475
|
-
);
|
|
476
|
-
if (!circular)
|
|
477
|
-
return [false, updatedVisited];
|
|
478
|
-
}
|
|
479
|
-
return [false, visited];
|
|
480
|
-
};
|
|
481
|
-
var detectCircularDependencies = (graph) => {
|
|
482
|
-
const { safeFiles, circularFiles, visited } = Array.from(graph.keys()).reduce(
|
|
483
|
-
(acc, filename) => {
|
|
484
|
-
const [isCircular, updatedVisited] = visit(
|
|
485
|
-
filename,
|
|
486
|
-
graph,
|
|
487
|
-
acc.visited,
|
|
488
|
-
/* @__PURE__ */ new Set()
|
|
489
|
-
);
|
|
490
|
-
if (isCircular) {
|
|
491
|
-
acc.circularFiles.push(filename);
|
|
492
|
-
} else {
|
|
493
|
-
acc.safeFiles.push(filename);
|
|
494
|
-
}
|
|
495
|
-
acc.visited = updatedVisited;
|
|
496
|
-
return acc;
|
|
497
|
-
},
|
|
498
|
-
{ safeFiles: [], circularFiles: [], visited: /* @__PURE__ */ new Set() }
|
|
499
|
-
);
|
|
500
|
-
return { safeFiles, circularFiles };
|
|
501
|
-
};
|
|
502
569
|
var compileAll = async (parsedArgs) => {
|
|
503
|
-
let
|
|
570
|
+
let compilePromises = [];
|
|
504
571
|
const contractFilenames = await (0, import_fast_glob.default)(
|
|
505
572
|
["**/*.ligo", "**/*.religo", "**/*.mligo", "**/*.jsligo"],
|
|
506
573
|
{
|
|
@@ -508,22 +575,15 @@ var compileAll = async (parsedArgs) => {
|
|
|
508
575
|
absolute: false
|
|
509
576
|
}
|
|
510
577
|
);
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
578
|
+
for (const filename of contractFilenames) {
|
|
579
|
+
if (isStorageListFile(filename) || isParameterListFile(filename))
|
|
580
|
+
continue;
|
|
581
|
+
const moduleNames = await listContractModules(parsedArgs, filename);
|
|
582
|
+
for (const moduleName of moduleNames) {
|
|
583
|
+
compilePromises.push(compileContractWithStorageAndParameter(parsedArgs, filename, moduleName));
|
|
516
584
|
}
|
|
517
585
|
}
|
|
518
|
-
return Promise.all(
|
|
519
|
-
if (circularFiles.length > 0) {
|
|
520
|
-
console.warn(
|
|
521
|
-
"Warning: Circular dependencies detected in the following files. They have been skipped:"
|
|
522
|
-
);
|
|
523
|
-
console.warn(circularFiles.join(", "));
|
|
524
|
-
}
|
|
525
|
-
return table;
|
|
526
|
-
}).then(import_node_sdk4.sendJsonRes).catch((err) => (0, import_node_sdk4.sendErr)(err, false));
|
|
586
|
+
return Promise.all(compilePromises).then((tables) => tables.flat()).then(import_node_sdk4.sendJsonRes).catch((err) => (0, import_node_sdk4.sendErr)(err, false));
|
|
527
587
|
};
|
|
528
588
|
var compile_all_default = compileAll;
|
|
529
589
|
|
|
@@ -551,7 +611,7 @@ var getArbitraryLigoCmd = (parsedArgs, uid, gid, userArgs) => {
|
|
|
551
611
|
const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter(
|
|
552
612
|
(arg) => arg
|
|
553
613
|
);
|
|
554
|
-
const args = baseArgs
|
|
614
|
+
const args = [...baseArgs, ...processedUserArgs, "--skip-analytics"];
|
|
555
615
|
const envVars = { "DOCKER_DEFAULT_PLATFORM": "linux/amd64" };
|
|
556
616
|
return [
|
|
557
617
|
[binary, ...args].join(" "),
|
|
@@ -668,6 +728,12 @@ import_node_sdk9.Plugin.create((i18n) => ({
|
|
|
668
728
|
flag: "json",
|
|
669
729
|
boolean: true,
|
|
670
730
|
description: "Emit JSON-encoded Michelson"
|
|
731
|
+
}),
|
|
732
|
+
import_node_sdk9.Option.create({
|
|
733
|
+
flag: "module",
|
|
734
|
+
shortFlag: "m",
|
|
735
|
+
type: "string",
|
|
736
|
+
description: "The LIGO module to be compiled"
|
|
671
737
|
})
|
|
672
738
|
],
|
|
673
739
|
handler: "proxy",
|
|
@@ -725,6 +791,7 @@ import_node_sdk9.Plugin.create((i18n) => ({
|
|
|
725
791
|
handler: createContract_default
|
|
726
792
|
})
|
|
727
793
|
],
|
|
728
|
-
proxy: main_default
|
|
794
|
+
proxy: main_default,
|
|
795
|
+
postInstall: `node ${__dirname}/postinstall.js`
|
|
729
796
|
}), process.argv);
|
|
730
797
|
//# sourceMappingURL=index.js.map
|