@taqueria/plugin-ligo 0.24.1 → 0.24.2
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/README.md +7 -10
- package/_readme.eta +12 -11
- package/common.ts +12 -2
- package/compile.ts +106 -60
- package/index.js +102 -53
- package/index.js.map +1 -1
- package/index.ts +8 -1
- package/ligo.ts +2 -2
- package/main.ts +4 -2
- package/package.json +2 -2
- package/test.ts +4 -5
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The LIGO plugin provides a task to compile LIGO smart contracts to Michelson `.t
|
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
|
-
- Taqueria v0.24.
|
|
7
|
+
- Taqueria v0.24.2 or later
|
|
8
8
|
- Node.js v16.17.1 or later
|
|
9
9
|
- Docker v20.10.12 or later
|
|
10
10
|
|
|
@@ -32,23 +32,20 @@ The LIGO plugin exposes a `compile` task in Taqueria which can target one LIGO c
|
|
|
32
32
|
### A frictionless smart contract development workflow
|
|
33
33
|
Our LIGO plugin introduces a smart contract development workflow by means of two simple file naming formats
|
|
34
34
|
|
|
35
|
-
Suppose you have a contract named `hello.mligo` and you create a file in the same directory as the contract with the naming format of `CONTRACT.
|
|
35
|
+
Suppose you have a contract named `hello.mligo` and you create a file in the same directory as the contract with the naming format of `CONTRACT.storageList.EXT`, where `CONTRACT` is the name of the contract this storage list file is associated with and `EXT` must match the extension of the associated contract. In our case, the former is `hello` and the latter is `mligo`, so it'd be named `hello.storageList.mligo`
|
|
36
36
|
|
|
37
|
-
You can define a list of LIGO variables in `hello.
|
|
37
|
+
You can define a list of LIGO variables in `hello.storageList.mligo` in the form of `let VARIABLE_NAME: STORAGE_TYPE = EXPRESSION` (explicit typing is optional but recommended) and the expressions will be treated as initial storage values for `hello.mligo`
|
|
38
38
|
|
|
39
39
|
> ### :page_with_curl: Note
|
|
40
40
|
> Note that the form is actually mligo code. Variable definitions in other syntax variants will differ.
|
|
41
41
|
|
|
42
|
-
Similarly with `hello.
|
|
42
|
+
Similarly with `hello.parameterList.mligo` but in the form of `let VARIABLE_NAME: PARAMETER_TYPE = EXPRESSION`
|
|
43
43
|
|
|
44
|
-
`taq compile hello.
|
|
44
|
+
`taq compile hello.storageList.mligo` will compile each definition in `hello.storageList.mligo` and will produce a Michelson `.tz` file that contains the storage value, as a Michelson expression, for each of them. If the name of a variable is `storage1`, then its emitted Michelson file will be named `hello.storage.storage1.tz`. For `taq compile hello.parameterList.mligo`, the name will be `hello.parameter.param1.tz` if there's a variable named `param1` defined in `hello.parameterList.mligo`
|
|
45
45
|
|
|
46
|
-
Furthermore, the first variable definition in `hello.
|
|
46
|
+
Furthermore, the first variable definition in `hello.storageList.mligo` will be treated as the default storage and will produce a Michelson file named `hello.default_storage.tz` instead. The `deploy` task from the Taquito plugin will take advantage of this. Go to that plugin documentation to learn how
|
|
47
47
|
|
|
48
|
-
Lastly, `taq compile hello.mligo` will compile `hello.mligo` and emit `hello.tz`. Then it'll look for `hello.
|
|
49
|
-
|
|
50
|
-
> ### :warning: CAUTION
|
|
51
|
-
> Make sure you name it `hello.storages.mligo` and not `hello.storage.mligo` (note the extra `s`)
|
|
48
|
+
Lastly, `taq compile hello.mligo` will compile `hello.mligo` and emit `hello.tz`. Then it'll look for `hello.storageList.mligo` and `hello.parameterList.mligo` and compile them too if they are found
|
|
52
49
|
|
|
53
50
|
### Options
|
|
54
51
|
|
package/_readme.eta
CHANGED
|
@@ -6,17 +6,22 @@ The LIGO plugin provides a task to compile LIGO smart contracts to Michelson `.t
|
|
|
6
6
|
|
|
7
7
|
## Requirements
|
|
8
8
|
|
|
9
|
-
- Taqueria v0.24.
|
|
9
|
+
- Taqueria v0.24.2 or later
|
|
10
10
|
- Node.js v16.17.1 or later
|
|
11
11
|
- Docker v20.10.12 or later
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
To install the LIGO plugin on a Taqueria project, navigate to the project folder and run:
|
|
16
|
+
|
|
16
17
|
```shell
|
|
17
18
|
taq install @taqueria/plugin-ligo
|
|
18
19
|
```
|
|
19
20
|
|
|
21
|
+
<%~ it.noteOpenAdmonition %>
|
|
22
|
+
You can override the Ligo version used by the plugin by creating the environment variable `TAQ_LIGO_IMAGE` and setting it to your desired Ligo Docker image
|
|
23
|
+
<%= it.closeAdmonition %>
|
|
24
|
+
|
|
20
25
|
## The `taq compile` Task
|
|
21
26
|
|
|
22
27
|
Basic usage is:
|
|
@@ -35,25 +40,21 @@ The LIGO plugin exposes a `compile` task in Taqueria which can target one LIGO c
|
|
|
35
40
|
### A frictionless smart contract development workflow
|
|
36
41
|
Our LIGO plugin introduces a smart contract development workflow by means of two simple file naming formats
|
|
37
42
|
|
|
38
|
-
Suppose you have a contract named `hello.mligo` and you create a file in the same directory as the contract with the naming format of `CONTRACT.
|
|
43
|
+
Suppose you have a contract named `hello.mligo` and you create a file in the same directory as the contract with the naming format of `CONTRACT.storageList.EXT`, where `CONTRACT` is the name of the contract this storage list file is associated with and `EXT` must match the extension of the associated contract. In our case, the former is `hello` and the latter is `mligo`, so it'd be named `hello.storageList.mligo`
|
|
39
44
|
|
|
40
|
-
You can define a list of LIGO variables in `hello.
|
|
45
|
+
You can define a list of LIGO variables in `hello.storageList.mligo` in the form of `let VARIABLE_NAME: STORAGE_TYPE = EXPRESSION` (explicit typing is optional but recommended) and the expressions will be treated as initial storage values for `hello.mligo`
|
|
41
46
|
|
|
42
47
|
<%~ it.noteOpenAdmonition %>
|
|
43
48
|
Note that the form is actually mligo code. Variable definitions in other syntax variants will differ.
|
|
44
49
|
<%= it.closeAdmonition %>
|
|
45
50
|
|
|
46
|
-
Similarly with `hello.
|
|
51
|
+
Similarly with `hello.parameterList.mligo` but in the form of `let VARIABLE_NAME: PARAMETER_TYPE = EXPRESSION`
|
|
47
52
|
|
|
48
|
-
`taq compile hello.
|
|
53
|
+
`taq compile hello.storageList.mligo` will compile each definition in `hello.storageList.mligo` and will produce a Michelson `.tz` file that contains the storage value, as a Michelson expression, for each of them. If the name of a variable is `storage1`, then its emitted Michelson file will be named `hello.storage.storage1.tz`. For `taq compile hello.parameterList.mligo`, the name will be `hello.parameter.param1.tz` if there's a variable named `param1` defined in `hello.parameterList.mligo`
|
|
49
54
|
|
|
50
|
-
Furthermore, the first variable definition in `hello.
|
|
55
|
+
Furthermore, the first variable definition in `hello.storageList.mligo` will be treated as the default storage and will produce a Michelson file named `hello.default_storage.tz` instead. The `deploy` task from the Taquito plugin will take advantage of this. Go to that plugin documentation to learn how
|
|
51
56
|
|
|
52
|
-
Lastly, `taq compile hello.mligo` will compile `hello.mligo` and emit `hello.tz`. Then it'll look for `hello.
|
|
53
|
-
|
|
54
|
-
<%~ it.cautionOpenAdmonition %>
|
|
55
|
-
Make sure you name it `hello.storages.mligo` and not `hello.storage.mligo` (note the extra `s`)
|
|
56
|
-
<%= it.closeAdmonition %>
|
|
57
|
+
Lastly, `taq compile hello.mligo` will compile `hello.mligo` and emit `hello.tz`. Then it'll look for `hello.storageList.mligo` and `hello.parameterList.mligo` and compile them too if they are found
|
|
57
58
|
|
|
58
59
|
### Options
|
|
59
60
|
|
package/common.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getDockerImage, sendErr } from '@taqueria/node-sdk';
|
|
1
2
|
import { RequestArgs } from '@taqueria/node-sdk/types';
|
|
2
3
|
import { join } from 'path';
|
|
3
4
|
|
|
@@ -17,8 +18,17 @@ export type IntersectionOpts = LigoOpts & CompileOpts & TestOpts;
|
|
|
17
18
|
|
|
18
19
|
type UnionOpts = LigoOpts | CompileOpts | TestOpts;
|
|
19
20
|
|
|
20
|
-
//
|
|
21
|
-
|
|
21
|
+
// Should point to the latest stable version, so it needs to be updated as part of our release process.
|
|
22
|
+
const LIGO_DEFAULT_IMAGE = 'ligolang/ligo:0.54.1';
|
|
23
|
+
|
|
24
|
+
const LIGO_IMAGE_ENV_VAR = 'TAQ_LIGO_IMAGE';
|
|
25
|
+
|
|
26
|
+
export const getLigoDockerImage = (): string => getDockerImage(LIGO_DEFAULT_IMAGE, LIGO_IMAGE_ENV_VAR);
|
|
22
27
|
|
|
23
28
|
export const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>
|
|
24
29
|
join(parsedArgs.config.contractsDir, sourceFile);
|
|
30
|
+
|
|
31
|
+
export const emitExternalError = (err: unknown, sourceFile: string): void => {
|
|
32
|
+
sendErr(`\n=== For ${sourceFile} ===`);
|
|
33
|
+
err instanceof Error ? sendErr(err.message.replace(/Command failed.+?\n/, '')) : sendErr(err as any);
|
|
34
|
+
};
|
package/compile.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { execCmd, getArch, sendAsyncErr,
|
|
1
|
+
import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';
|
|
2
2
|
import { access, readFile, writeFile } from 'fs/promises';
|
|
3
3
|
import { basename, extname, join } from 'path';
|
|
4
|
-
import { CompileOpts as Opts, getInputFilename,
|
|
4
|
+
import { CompileOpts as Opts, emitExternalError, getInputFilename, getLigoDockerImage } from './common';
|
|
5
5
|
|
|
6
6
|
type TableRow = { contract: string; artifact: string };
|
|
7
7
|
|
|
@@ -13,13 +13,14 @@ const isStorageKind = (exprKind: ExprKind): boolean => exprKind === 'storage' ||
|
|
|
13
13
|
|
|
14
14
|
const isLIGOFile = (sourceFile: string): boolean => /.+\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const isStorageListFile = (sourceFile: string): boolean =>
|
|
17
|
+
/.+\.(storageList|storages)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
/.+\.parameters\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
19
|
+
const isParameterListFile = (sourceFile: string): boolean =>
|
|
20
|
+
/.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
20
21
|
|
|
21
22
|
const isContractFile = (sourceFile: string): boolean =>
|
|
22
|
-
isLIGOFile(sourceFile) && !
|
|
23
|
+
isLIGOFile(sourceFile) && !isStorageListFile(sourceFile) && !isParameterListFile(sourceFile);
|
|
23
24
|
|
|
24
25
|
const extractExt = (path: string): string => {
|
|
25
26
|
const matchResult = path.match(/\.(ligo|religo|mligo|jsligo)$/);
|
|
@@ -37,18 +38,18 @@ const getOutputFilename = (parsedArgs: Opts, sourceFile: string): string => {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
// Get the contract name that the storage/parameter file is associated with
|
|
40
|
-
// e.g. If sourceFile is token.
|
|
41
|
+
// e.g. If sourceFile is token.storageList.mligo, then it'll return token.mligo
|
|
41
42
|
const getContractNameForExpr = (sourceFile: string, exprKind: ExprKind): string => {
|
|
42
43
|
try {
|
|
43
44
|
return isStorageKind(exprKind)
|
|
44
|
-
? sourceFile.match(/.+(?=\.storages\.(ligo|religo|mligo|jsligo))/)!.join('.')
|
|
45
|
-
: sourceFile.match(/.+(?=\.parameters\.(ligo|religo|mligo|jsligo))/)!.join('.');
|
|
45
|
+
? sourceFile.match(/.+(?=\.(?:storageList|storages)\.(ligo|religo|mligo|jsligo))/)!.join('.')
|
|
46
|
+
: sourceFile.match(/.+(?=\.(?:parameterList|parameters)\.(ligo|religo|mligo|jsligo))/)!.join('.');
|
|
46
47
|
} catch (err) {
|
|
47
48
|
throw new Error(`Something went wrong internally when dealing with filename format: ${err}`);
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
// If sourceFile is token.
|
|
52
|
+
// If sourceFile is token.storageList.mligo, then it'll return token.storage.{storageName}.tz
|
|
52
53
|
const getOutputExprFileName = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind, exprName: string): string => {
|
|
53
54
|
const contractName = basename(getContractNameForExpr(sourceFile, exprKind), extname(sourceFile));
|
|
54
55
|
const outputFile = exprKind === 'default_storage'
|
|
@@ -61,7 +62,7 @@ const getCompileContractCmd = (parsedArgs: Opts, sourceFile: string): string =>
|
|
|
61
62
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
62
63
|
if (!projectDir) throw `No project directory provided`;
|
|
63
64
|
const baseCmd =
|
|
64
|
-
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${
|
|
65
|
+
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;
|
|
65
66
|
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
66
67
|
const outputFile = `-o ${getOutputFilename(parsedArgs, sourceFile)}`;
|
|
67
68
|
const cmd = `${baseCmd} ${inputFile} ${outputFile}`;
|
|
@@ -73,7 +74,7 @@ const getCompileExprCmd = (parsedArgs: Opts, sourceFile: string, exprKind: ExprK
|
|
|
73
74
|
if (!projectDir) throw `No project directory provided`;
|
|
74
75
|
const compilerType = isStorageKind(exprKind) ? 'storage' : 'parameter';
|
|
75
76
|
const baseCmd =
|
|
76
|
-
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${
|
|
77
|
+
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;
|
|
77
78
|
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
78
79
|
const outputFile = `-o ${getOutputExprFileName(parsedArgs, sourceFile, exprKind, exprName)}`;
|
|
79
80
|
const cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile}`;
|
|
@@ -92,8 +93,7 @@ const compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow
|
|
|
92
93
|
};
|
|
93
94
|
})
|
|
94
95
|
.catch(err => {
|
|
95
|
-
|
|
96
|
-
sendErr(err.message.replace(/Command failed.+?\n/, ''));
|
|
96
|
+
emitExternalError(err, sourceFile);
|
|
97
97
|
return {
|
|
98
98
|
contract: sourceFile,
|
|
99
99
|
artifact: COMPILE_ERR_MSG,
|
|
@@ -113,8 +113,7 @@ const compileExpr = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind) =
|
|
|
113
113
|
};
|
|
114
114
|
})
|
|
115
115
|
.catch(err => {
|
|
116
|
-
|
|
117
|
-
sendErr(err.message.replace(/Command failed.+?\n/, ''));
|
|
116
|
+
emitExternalError(err, sourceFile);
|
|
118
117
|
return {
|
|
119
118
|
contract: sourceFile,
|
|
120
119
|
artifact: COMPILE_ERR_MSG,
|
|
@@ -123,17 +122,7 @@ const compileExpr = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind) =
|
|
|
123
122
|
|
|
124
123
|
const compileExprs = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind): Promise<TableRow[]> =>
|
|
125
124
|
readFile(getInputFilename(parsedArgs, sourceFile), 'utf8')
|
|
126
|
-
.then(
|
|
127
|
-
if (!data.includes('#include')) {
|
|
128
|
-
await writeFile(
|
|
129
|
-
getInputFilename(parsedArgs, sourceFile),
|
|
130
|
-
`#include "${getContractNameForExpr(sourceFile, exprKind)}"\n` + data,
|
|
131
|
-
'utf8',
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
return data;
|
|
135
|
-
})
|
|
136
|
-
.then(data => data.match(/(?<=\s*(let|const)\s+)[a-zA-Z0-9_]+/g))
|
|
125
|
+
.then(data => data.match(/(?<=\n\s*(let|const)\s+)[a-zA-Z0-9_]+/g))
|
|
137
126
|
.then(exprNames => {
|
|
138
127
|
if (!exprNames) return [];
|
|
139
128
|
const firstExprName = exprNames.slice(0, 1)[0];
|
|
@@ -145,38 +134,95 @@ const compileExprs = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind):
|
|
|
145
134
|
return Promise.all([firstExprResult].concat(restExprResults));
|
|
146
135
|
})
|
|
147
136
|
.catch(err => {
|
|
148
|
-
|
|
149
|
-
sendErr(err.message);
|
|
137
|
+
emitExternalError(err, sourceFile);
|
|
150
138
|
return [{
|
|
151
139
|
contract: sourceFile,
|
|
152
|
-
artifact: `No ${isStorageKind(exprKind) ? '
|
|
140
|
+
artifact: `No ${isStorageKind(exprKind) ? 'storage' : 'parameter'} values compiled`,
|
|
153
141
|
}];
|
|
154
142
|
})
|
|
155
143
|
.then(mergeArtifactsOutput(sourceFile));
|
|
156
144
|
|
|
145
|
+
// TODO: Just for backwards compatibility. Can be deleted in the future.
|
|
146
|
+
const tryLegacyStorageNamingConvention = (parsedArgs: Opts, sourceFile: string) => {
|
|
147
|
+
const storageListFile = `${removeExt(sourceFile)}.storages${extractExt(sourceFile)}`;
|
|
148
|
+
const storageListFilename = getInputFilename(parsedArgs, storageListFile);
|
|
149
|
+
return access(storageListFilename).then(() => {
|
|
150
|
+
sendWarn(
|
|
151
|
+
`Warning: The naming convention of "<CONTRACT>.storages.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.storageList.<EXTENSION>". Please adjust your storage file names accordingly\n`,
|
|
152
|
+
);
|
|
153
|
+
return compileExprs(parsedArgs, storageListFile, 'storage');
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// TODO: Just for backwards compatibility. Can be deleted in the future.
|
|
158
|
+
const tryLegacyParameterNamingConvention = (parsedArgs: Opts, sourceFile: string) => {
|
|
159
|
+
const parameterListFile = `${removeExt(sourceFile)}.parameters${extractExt(sourceFile)}`;
|
|
160
|
+
const parameterListFilename = getInputFilename(parsedArgs, parameterListFile);
|
|
161
|
+
return access(parameterListFilename).then(() => {
|
|
162
|
+
sendWarn(
|
|
163
|
+
`Warning: The naming convention of "<CONTRACT>.parameters.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.parameterList.<EXTENSION>". Please adjust your parameter file names accordingly\n`,
|
|
164
|
+
);
|
|
165
|
+
return compileExprs(parsedArgs, parameterListFile, 'parameter');
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const initContentForStorage = (sourceFile: string): string => {
|
|
170
|
+
const linkToContract = `#include "${sourceFile}"\n\n`;
|
|
171
|
+
|
|
172
|
+
const instruction =
|
|
173
|
+
'// Define your initial storage values as a list of LIGO variable definitions,\n// the first of which will be considered the default value to be used for origination later on\n';
|
|
174
|
+
|
|
175
|
+
const ext = extractExt(sourceFile);
|
|
176
|
+
let syntax = '';
|
|
177
|
+
if (ext === '.ligo') syntax = '// E.g. const aStorageValue : aStorageType = 10;\n\n';
|
|
178
|
+
else if (ext === '.religo') syntax = '// E.g. let aStorageValue : aStorageType = 10;\n\n';
|
|
179
|
+
else if (ext === '.mligo') syntax = '// E.g. let aStorageValue : aStorageType = 10\n\n';
|
|
180
|
+
else if (ext === '.jsligo') syntax = '// E.g. const aStorageValue : aStorageType = 10;\n\n';
|
|
181
|
+
|
|
182
|
+
return linkToContract + instruction + syntax;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const initContentForParameter = (sourceFile: string): string => {
|
|
186
|
+
const linkToContract = `#include "${sourceFile}"\n\n`;
|
|
187
|
+
|
|
188
|
+
const instruction = '// Define your parameter values as a list of LIGO variable definitions\n';
|
|
189
|
+
|
|
190
|
+
const ext = extractExt(sourceFile);
|
|
191
|
+
let syntax = '';
|
|
192
|
+
if (ext === '.ligo') syntax = '// E.g. const aParameterValue : aParameterType = Increment(1);\n\n';
|
|
193
|
+
else if (ext === '.religo') syntax = '// E.g. let aParameterValue : aParameterType = (Increment (1));\n\n';
|
|
194
|
+
else if (ext === '.mligo') syntax = '// E.g. let aParameterValue : aParameterType = Increment 1\n\n';
|
|
195
|
+
else if (ext === '.jsligo') syntax = '// E.g. const aParameterValue : aParameterType = (Increment (1));\n\n';
|
|
196
|
+
|
|
197
|
+
return linkToContract + instruction + syntax;
|
|
198
|
+
};
|
|
199
|
+
|
|
157
200
|
const compileContractWithStorageAndParameter = async (parsedArgs: Opts, sourceFile: string): Promise<TableRow[]> => {
|
|
158
201
|
const contractCompileResult = await compileContract(parsedArgs, sourceFile);
|
|
159
202
|
if (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];
|
|
160
203
|
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const storageCompileResult = await access(storagesFilename)
|
|
167
|
-
.then(() => compileExprs(parsedArgs, storagesFile, 'storage'))
|
|
204
|
+
const storageListFile = `${removeExt(sourceFile)}.storageList${extractExt(sourceFile)}`;
|
|
205
|
+
const storageListFilename = getInputFilename(parsedArgs, storageListFile);
|
|
206
|
+
const storageCompileResult = await access(storageListFilename)
|
|
207
|
+
.then(() => compileExprs(parsedArgs, storageListFile, 'storage'))
|
|
208
|
+
.catch(() => tryLegacyStorageNamingConvention(parsedArgs, sourceFile))
|
|
168
209
|
.catch(() => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
210
|
+
sendWarn(
|
|
211
|
+
`Note: storage file associated with "${sourceFile}" can't be found, so "${storageListFile}" has been created for you. Use this file to define all initial storage values for this contract\n`,
|
|
212
|
+
);
|
|
213
|
+
writeFile(storageListFilename, initContentForStorage(sourceFile), 'utf8');
|
|
172
214
|
});
|
|
173
215
|
|
|
174
|
-
const
|
|
175
|
-
|
|
216
|
+
const parameterListFile = `${removeExt(sourceFile)}.parameterList${extractExt(sourceFile)}`;
|
|
217
|
+
const parameterListFilename = getInputFilename(parsedArgs, parameterListFile);
|
|
218
|
+
const parameterCompileResult = await access(parameterListFilename)
|
|
219
|
+
.then(() => compileExprs(parsedArgs, parameterListFile, 'parameter'))
|
|
220
|
+
.catch(() => tryLegacyParameterNamingConvention(parsedArgs, sourceFile))
|
|
176
221
|
.catch(() => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
222
|
+
sendWarn(
|
|
223
|
+
`Note: parameter file associated with "${sourceFile}" can't be found, so "${parameterListFile}" has been created for you. Use this file to define all parameter values for this contract\n`,
|
|
224
|
+
);
|
|
225
|
+
writeFile(parameterListFilename, initContentForParameter(sourceFile), 'utf8');
|
|
180
226
|
});
|
|
181
227
|
|
|
182
228
|
let compileResults: TableRow[] = [contractCompileResult];
|
|
@@ -190,20 +236,20 @@ Compiling storage/parameter file amounts to compiling multiple expressions in th
|
|
|
190
236
|
resulting in multiple rows with the same file name but different artifact names.
|
|
191
237
|
This will merge these rows into one row with just one mention of the file name.
|
|
192
238
|
e.g.
|
|
193
|
-
|
|
194
|
-
│ Contract
|
|
195
|
-
|
|
196
|
-
│ hello.
|
|
197
|
-
|
|
198
|
-
│ hello.
|
|
199
|
-
|
|
239
|
+
┌─────────────────────────┬─────────────────────────────────────────────┐
|
|
240
|
+
│ Contract │ Artifact │
|
|
241
|
+
├─────────────────────────┼─────────────────────────────────────────────┤
|
|
242
|
+
│ hello.storageList.mligo │ artifacts/hello.default_storage.storage1.tz │
|
|
243
|
+
├─────────────────────────┼─────────────────────────────────────────────┤
|
|
244
|
+
│ hello.storageList.mligo │ artifacts/hello.storage.storage2.tz │
|
|
245
|
+
└─────────────────────────┴─────────────────────────────────────────────┘
|
|
200
246
|
versus
|
|
201
|
-
|
|
202
|
-
│ Contract
|
|
203
|
-
|
|
204
|
-
│ hello.
|
|
205
|
-
│
|
|
206
|
-
|
|
247
|
+
┌─────────────────────────┬─────────────────────────────────────────────┐
|
|
248
|
+
│ Contract │ Artifact │
|
|
249
|
+
├─────────────────────────┼─────────────────────────────────────────────┤
|
|
250
|
+
│ hello.storageList.mligo │ artifacts/hello.default_storage.storage1.tz │
|
|
251
|
+
│ │ artifacts/hello.storage.storage2.tz │
|
|
252
|
+
└─────────────────────────┴─────────────────────────────────────────────┘
|
|
207
253
|
*/
|
|
208
254
|
const mergeArtifactsOutput = (sourceFile: string) =>
|
|
209
255
|
(tableRows: TableRow[]): TableRow[] => {
|
|
@@ -220,8 +266,8 @@ const mergeArtifactsOutput = (sourceFile: string) =>
|
|
|
220
266
|
const compile = (parsedArgs: Opts): Promise<void> => {
|
|
221
267
|
const sourceFile = parsedArgs.sourceFile;
|
|
222
268
|
let p: Promise<TableRow[]>;
|
|
223
|
-
if (
|
|
224
|
-
else if (
|
|
269
|
+
if (isStorageListFile(sourceFile)) p = compileExprs(parsedArgs, sourceFile, 'storage');
|
|
270
|
+
else if (isParameterListFile(sourceFile)) p = compileExprs(parsedArgs, sourceFile, 'parameter');
|
|
225
271
|
else if (isContractFile(sourceFile)) p = compileContractWithStorageAndParameter(parsedArgs, sourceFile);
|
|
226
272
|
else {
|
|
227
273
|
return sendAsyncErr(
|
package/index.js
CHANGED
|
@@ -143,18 +143,27 @@ var $40622e3a438d0515$export$2e2bcd8739ae039 = $40622e3a438d0515$var$createContr
|
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
|
|
146
|
+
// Should point to the latest stable version, so it needs to be updated as part of our release process.
|
|
147
|
+
const $844cb58d66fbf6db$var$LIGO_DEFAULT_IMAGE = "ligolang/ligo:0.54.1";
|
|
148
|
+
const $844cb58d66fbf6db$var$LIGO_IMAGE_ENV_VAR = "TAQ_LIGO_IMAGE";
|
|
149
|
+
const $844cb58d66fbf6db$export$2b403d61ac8ea302 = ()=>(0, $kQNfl$taquerianodesdk.getDockerImage)($844cb58d66fbf6db$var$LIGO_DEFAULT_IMAGE, $844cb58d66fbf6db$var$LIGO_IMAGE_ENV_VAR);
|
|
150
|
+
const $844cb58d66fbf6db$export$17f107107c3c82c6 = (parsedArgs, sourceFile)=>(0, $kQNfl$path.join)(parsedArgs.config.contractsDir, sourceFile);
|
|
151
|
+
const $844cb58d66fbf6db$export$b59ff90dc389ce6d = (err, sourceFile)=>{
|
|
152
|
+
(0, $kQNfl$taquerianodesdk.sendErr)(`\n=== For ${sourceFile} ===`);
|
|
153
|
+
err instanceof Error ? (0, $kQNfl$taquerianodesdk.sendErr)(err.message.replace(/Command failed.+?\n/, "")) : (0, $kQNfl$taquerianodesdk.sendErr)(err);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
|
|
146
157
|
|
|
147
158
|
|
|
148
|
-
const $844cb58d66fbf6db$export$9bb5edf1683d4462 = "ligolang/ligo:0.55.0";
|
|
149
|
-
const $844cb58d66fbf6db$export$17f107107c3c82c6 = (parsedArgs, sourceFile)=>(0, $kQNfl$path.join)(parsedArgs.config.contractsDir, sourceFile);
|
|
150
159
|
|
|
151
160
|
|
|
152
161
|
const $24b2f47d8f306cb3$var$COMPILE_ERR_MSG = "Not compiled";
|
|
153
162
|
const $24b2f47d8f306cb3$var$isStorageKind = (exprKind)=>exprKind === "storage" || exprKind === "default_storage";
|
|
154
163
|
const $24b2f47d8f306cb3$var$isLIGOFile = (sourceFile)=>/.+\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
155
|
-
const $24b2f47d8f306cb3$var$
|
|
156
|
-
const $24b2f47d8f306cb3$var$
|
|
157
|
-
const $24b2f47d8f306cb3$var$isContractFile = (sourceFile)=>$24b2f47d8f306cb3$var$isLIGOFile(sourceFile) && !$24b2f47d8f306cb3$var$
|
|
164
|
+
const $24b2f47d8f306cb3$var$isStorageListFile = (sourceFile)=>/.+\.(storageList|storages)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
165
|
+
const $24b2f47d8f306cb3$var$isParameterListFile = (sourceFile)=>/.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
166
|
+
const $24b2f47d8f306cb3$var$isContractFile = (sourceFile)=>$24b2f47d8f306cb3$var$isLIGOFile(sourceFile) && !$24b2f47d8f306cb3$var$isStorageListFile(sourceFile) && !$24b2f47d8f306cb3$var$isParameterListFile(sourceFile);
|
|
158
167
|
const $24b2f47d8f306cb3$var$extractExt = (path)=>{
|
|
159
168
|
const matchResult = path.match(/\.(ligo|religo|mligo|jsligo)$/);
|
|
160
169
|
return matchResult ? matchResult[0] : "";
|
|
@@ -168,15 +177,15 @@ const $24b2f47d8f306cb3$var$getOutputFilename = (parsedArgs, sourceFile)=>{
|
|
|
168
177
|
return (0, $kQNfl$path.join)(parsedArgs.config.artifactsDir, `${outputFile}.tz`);
|
|
169
178
|
};
|
|
170
179
|
// Get the contract name that the storage/parameter file is associated with
|
|
171
|
-
// e.g. If sourceFile is token.
|
|
180
|
+
// e.g. If sourceFile is token.storageList.mligo, then it'll return token.mligo
|
|
172
181
|
const $24b2f47d8f306cb3$var$getContractNameForExpr = (sourceFile, exprKind)=>{
|
|
173
182
|
try {
|
|
174
|
-
return $24b2f47d8f306cb3$var$isStorageKind(exprKind) ? sourceFile.match(/.+(?=\.storages\.(ligo|religo|mligo|jsligo))/).join(".") : sourceFile.match(/.+(?=\.parameters\.(ligo|religo|mligo|jsligo))/).join(".");
|
|
183
|
+
return $24b2f47d8f306cb3$var$isStorageKind(exprKind) ? sourceFile.match(/.+(?=\.(?:storageList|storages)\.(ligo|religo|mligo|jsligo))/).join(".") : sourceFile.match(/.+(?=\.(?:parameterList|parameters)\.(ligo|religo|mligo|jsligo))/).join(".");
|
|
175
184
|
} catch (err) {
|
|
176
185
|
throw new Error(`Something went wrong internally when dealing with filename format: ${err}`);
|
|
177
186
|
}
|
|
178
187
|
};
|
|
179
|
-
// If sourceFile is token.
|
|
188
|
+
// If sourceFile is token.storageList.mligo, then it'll return token.storage.{storageName}.tz
|
|
180
189
|
const $24b2f47d8f306cb3$var$getOutputExprFileName = (parsedArgs, sourceFile, exprKind, exprName)=>{
|
|
181
190
|
const contractName = (0, $kQNfl$path.basename)($24b2f47d8f306cb3$var$getContractNameForExpr(sourceFile, exprKind), (0, $kQNfl$path.extname)(sourceFile));
|
|
182
191
|
const outputFile = exprKind === "default_storage" ? `${contractName}.default_storage.tz` : `${contractName}.${exprKind}.${exprName}.tz`;
|
|
@@ -185,7 +194,7 @@ const $24b2f47d8f306cb3$var$getOutputExprFileName = (parsedArgs, sourceFile, exp
|
|
|
185
194
|
const $24b2f47d8f306cb3$var$getCompileContractCmd = (parsedArgs, sourceFile)=>{
|
|
186
195
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
187
196
|
if (!projectDir) throw `No project directory provided`;
|
|
188
|
-
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$
|
|
197
|
+
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$2b403d61ac8ea302)()} compile contract`;
|
|
189
198
|
const inputFile = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile);
|
|
190
199
|
const outputFile = `-o ${$24b2f47d8f306cb3$var$getOutputFilename(parsedArgs, sourceFile)}`;
|
|
191
200
|
const cmd = `${baseCmd} ${inputFile} ${outputFile}`;
|
|
@@ -195,7 +204,7 @@ const $24b2f47d8f306cb3$var$getCompileExprCmd = (parsedArgs, sourceFile, exprKin
|
|
|
195
204
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
196
205
|
if (!projectDir) throw `No project directory provided`;
|
|
197
206
|
const compilerType = $24b2f47d8f306cb3$var$isStorageKind(exprKind) ? "storage" : "parameter";
|
|
198
|
-
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$
|
|
207
|
+
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$2b403d61ac8ea302)()} compile ${compilerType}`;
|
|
199
208
|
const inputFile = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile);
|
|
200
209
|
const outputFile = `-o ${$24b2f47d8f306cb3$var$getOutputExprFileName(parsedArgs, sourceFile, exprKind, exprName)}`;
|
|
201
210
|
const cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile}`;
|
|
@@ -208,8 +217,7 @@ const $24b2f47d8f306cb3$var$compileContract = (parsedArgs, sourceFile)=>(0, $kQN
|
|
|
208
217
|
artifact: $24b2f47d8f306cb3$var$getOutputFilename(parsedArgs, sourceFile)
|
|
209
218
|
};
|
|
210
219
|
}).catch((err)=>{
|
|
211
|
-
(0, $
|
|
212
|
-
(0, $kQNfl$taquerianodesdk.sendErr)(err.message.replace(/Command failed.+?\n/, ""));
|
|
220
|
+
(0, $844cb58d66fbf6db$export$b59ff90dc389ce6d)(err, sourceFile);
|
|
213
221
|
return {
|
|
214
222
|
contract: sourceFile,
|
|
215
223
|
artifact: $24b2f47d8f306cb3$var$COMPILE_ERR_MSG
|
|
@@ -222,17 +230,13 @@ const $24b2f47d8f306cb3$var$compileExpr = (parsedArgs, sourceFile, exprKind)=>(e
|
|
|
222
230
|
artifact: $24b2f47d8f306cb3$var$getOutputExprFileName(parsedArgs, sourceFile, exprKind, exprName)
|
|
223
231
|
};
|
|
224
232
|
}).catch((err)=>{
|
|
225
|
-
(0, $
|
|
226
|
-
(0, $kQNfl$taquerianodesdk.sendErr)(err.message.replace(/Command failed.+?\n/, ""));
|
|
233
|
+
(0, $844cb58d66fbf6db$export$b59ff90dc389ce6d)(err, sourceFile);
|
|
227
234
|
return {
|
|
228
235
|
contract: sourceFile,
|
|
229
236
|
artifact: $24b2f47d8f306cb3$var$COMPILE_ERR_MSG
|
|
230
237
|
};
|
|
231
238
|
});
|
|
232
|
-
const $24b2f47d8f306cb3$var$compileExprs = (parsedArgs, sourceFile, exprKind)=>(0, $kQNfl$fspromises.readFile)((0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile), "utf8").then(
|
|
233
|
-
if (!data.includes("#include")) await (0, $kQNfl$fspromises.writeFile)((0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile), `#include "${$24b2f47d8f306cb3$var$getContractNameForExpr(sourceFile, exprKind)}"\n` + data, "utf8");
|
|
234
|
-
return data;
|
|
235
|
-
}).then((data)=>data.match(/(?<=\s*(let|const)\s+)[a-zA-Z0-9_]+/g)).then((exprNames)=>{
|
|
239
|
+
const $24b2f47d8f306cb3$var$compileExprs = (parsedArgs, sourceFile, exprKind)=>(0, $kQNfl$fspromises.readFile)((0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile), "utf8").then((data)=>data.match(/(?<=\n\s*(let|const)\s+)[a-zA-Z0-9_]+/g)).then((exprNames)=>{
|
|
236
240
|
if (!exprNames) return [];
|
|
237
241
|
const firstExprName = exprNames.slice(0, 1)[0];
|
|
238
242
|
const restExprNames = exprNames.slice(1, exprNames.length);
|
|
@@ -244,33 +248,70 @@ const $24b2f47d8f306cb3$var$compileExprs = (parsedArgs, sourceFile, exprKind)=>(
|
|
|
244
248
|
firstExprResult
|
|
245
249
|
].concat(restExprResults));
|
|
246
250
|
}).catch((err)=>{
|
|
247
|
-
(0, $
|
|
248
|
-
(0, $kQNfl$taquerianodesdk.sendErr)(err.message);
|
|
251
|
+
(0, $844cb58d66fbf6db$export$b59ff90dc389ce6d)(err, sourceFile);
|
|
249
252
|
return [
|
|
250
253
|
{
|
|
251
254
|
contract: sourceFile,
|
|
252
|
-
artifact: `No ${$24b2f47d8f306cb3$var$isStorageKind(exprKind) ? "
|
|
255
|
+
artifact: `No ${$24b2f47d8f306cb3$var$isStorageKind(exprKind) ? "storage" : "parameter"} values compiled`
|
|
253
256
|
}
|
|
254
257
|
];
|
|
255
258
|
}).then($24b2f47d8f306cb3$var$mergeArtifactsOutput(sourceFile));
|
|
259
|
+
// TODO: Just for backwards compatibility. Can be deleted in the future.
|
|
260
|
+
const $24b2f47d8f306cb3$var$tryLegacyStorageNamingConvention = (parsedArgs, sourceFile)=>{
|
|
261
|
+
const storageListFile = `${$24b2f47d8f306cb3$var$removeExt(sourceFile)}.storages${$24b2f47d8f306cb3$var$extractExt(sourceFile)}`;
|
|
262
|
+
const storageListFilename = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, storageListFile);
|
|
263
|
+
return (0, $kQNfl$fspromises.access)(storageListFilename).then(()=>{
|
|
264
|
+
(0, $kQNfl$taquerianodesdk.sendWarn)(`Warning: The naming convention of "<CONTRACT>.storages.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.storageList.<EXTENSION>". Please adjust your storage file names accordingly\n`);
|
|
265
|
+
return $24b2f47d8f306cb3$var$compileExprs(parsedArgs, storageListFile, "storage");
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
// TODO: Just for backwards compatibility. Can be deleted in the future.
|
|
269
|
+
const $24b2f47d8f306cb3$var$tryLegacyParameterNamingConvention = (parsedArgs, sourceFile)=>{
|
|
270
|
+
const parameterListFile = `${$24b2f47d8f306cb3$var$removeExt(sourceFile)}.parameters${$24b2f47d8f306cb3$var$extractExt(sourceFile)}`;
|
|
271
|
+
const parameterListFilename = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, parameterListFile);
|
|
272
|
+
return (0, $kQNfl$fspromises.access)(parameterListFilename).then(()=>{
|
|
273
|
+
(0, $kQNfl$taquerianodesdk.sendWarn)(`Warning: The naming convention of "<CONTRACT>.parameters.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.parameterList.<EXTENSION>". Please adjust your parameter file names accordingly\n`);
|
|
274
|
+
return $24b2f47d8f306cb3$var$compileExprs(parsedArgs, parameterListFile, "parameter");
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
const $24b2f47d8f306cb3$var$initContentForStorage = (sourceFile)=>{
|
|
278
|
+
const linkToContract = `#include "${sourceFile}"\n\n`;
|
|
279
|
+
const instruction = "// Define your initial storage values as a list of LIGO variable definitions,\n// the first of which will be considered the default value to be used for origination later on\n";
|
|
280
|
+
const ext = $24b2f47d8f306cb3$var$extractExt(sourceFile);
|
|
281
|
+
let syntax = "";
|
|
282
|
+
if (ext === ".ligo") syntax = "// E.g. const aStorageValue : aStorageType = 10;\n\n";
|
|
283
|
+
else if (ext === ".religo") syntax = "// E.g. let aStorageValue : aStorageType = 10;\n\n";
|
|
284
|
+
else if (ext === ".mligo") syntax = "// E.g. let aStorageValue : aStorageType = 10\n\n";
|
|
285
|
+
else if (ext === ".jsligo") syntax = "// E.g. const aStorageValue : aStorageType = 10;\n\n";
|
|
286
|
+
return linkToContract + instruction + syntax;
|
|
287
|
+
};
|
|
288
|
+
const $24b2f47d8f306cb3$var$initContentForParameter = (sourceFile)=>{
|
|
289
|
+
const linkToContract = `#include "${sourceFile}"\n\n`;
|
|
290
|
+
const instruction = "// Define your parameter values as a list of LIGO variable definitions\n";
|
|
291
|
+
const ext = $24b2f47d8f306cb3$var$extractExt(sourceFile);
|
|
292
|
+
let syntax = "";
|
|
293
|
+
if (ext === ".ligo") syntax = "// E.g. const aParameterValue : aParameterType = Increment(1);\n\n";
|
|
294
|
+
else if (ext === ".religo") syntax = "// E.g. let aParameterValue : aParameterType = (Increment (1));\n\n";
|
|
295
|
+
else if (ext === ".mligo") syntax = "// E.g. let aParameterValue : aParameterType = Increment 1\n\n";
|
|
296
|
+
else if (ext === ".jsligo") syntax = "// E.g. const aParameterValue : aParameterType = (Increment (1));\n\n";
|
|
297
|
+
return linkToContract + instruction + syntax;
|
|
298
|
+
};
|
|
256
299
|
const $24b2f47d8f306cb3$var$compileContractWithStorageAndParameter = async (parsedArgs, sourceFile)=>{
|
|
257
300
|
const contractCompileResult = await $24b2f47d8f306cb3$var$compileContract(parsedArgs, sourceFile);
|
|
258
301
|
if (contractCompileResult.artifact === $24b2f47d8f306cb3$var$COMPILE_ERR_MSG) return [
|
|
259
302
|
contractCompileResult
|
|
260
303
|
];
|
|
261
|
-
const
|
|
262
|
-
const
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
// sendWarn(
|
|
267
|
-
// `Note: storage file associated with "${sourceFile}" can't be found. You should create a file "${storagesFile}" and define initial storage values as a list of LIGO variable definitions. e.g. "let STORAGE_NAME: storage = LIGO_EXPR" for CameLigo`,
|
|
268
|
-
// )
|
|
304
|
+
const storageListFile = `${$24b2f47d8f306cb3$var$removeExt(sourceFile)}.storageList${$24b2f47d8f306cb3$var$extractExt(sourceFile)}`;
|
|
305
|
+
const storageListFilename = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, storageListFile);
|
|
306
|
+
const storageCompileResult = await (0, $kQNfl$fspromises.access)(storageListFilename).then(()=>$24b2f47d8f306cb3$var$compileExprs(parsedArgs, storageListFile, "storage")).catch(()=>$24b2f47d8f306cb3$var$tryLegacyStorageNamingConvention(parsedArgs, sourceFile)).catch(()=>{
|
|
307
|
+
(0, $kQNfl$taquerianodesdk.sendWarn)(`Note: storage file associated with "${sourceFile}" can't be found, so "${storageListFile}" has been created for you. Use this file to define all initial storage values for this contract\n`);
|
|
308
|
+
(0, $kQNfl$fspromises.writeFile)(storageListFilename, $24b2f47d8f306cb3$var$initContentForStorage(sourceFile), "utf8");
|
|
269
309
|
});
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
310
|
+
const parameterListFile = `${$24b2f47d8f306cb3$var$removeExt(sourceFile)}.parameterList${$24b2f47d8f306cb3$var$extractExt(sourceFile)}`;
|
|
311
|
+
const parameterListFilename = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, parameterListFile);
|
|
312
|
+
const parameterCompileResult = await (0, $kQNfl$fspromises.access)(parameterListFilename).then(()=>$24b2f47d8f306cb3$var$compileExprs(parsedArgs, parameterListFile, "parameter")).catch(()=>$24b2f47d8f306cb3$var$tryLegacyParameterNamingConvention(parsedArgs, sourceFile)).catch(()=>{
|
|
313
|
+
(0, $kQNfl$taquerianodesdk.sendWarn)(`Note: parameter file associated with "${sourceFile}" can't be found, so "${parameterListFile}" has been created for you. Use this file to define all parameter values for this contract\n`);
|
|
314
|
+
(0, $kQNfl$fspromises.writeFile)(parameterListFilename, $24b2f47d8f306cb3$var$initContentForParameter(sourceFile), "utf8");
|
|
274
315
|
});
|
|
275
316
|
let compileResults = [
|
|
276
317
|
contractCompileResult
|
|
@@ -284,20 +325,20 @@ Compiling storage/parameter file amounts to compiling multiple expressions in th
|
|
|
284
325
|
resulting in multiple rows with the same file name but different artifact names.
|
|
285
326
|
This will merge these rows into one row with just one mention of the file name.
|
|
286
327
|
e.g.
|
|
287
|
-
|
|
288
|
-
│ Contract
|
|
289
|
-
|
|
290
|
-
│ hello.
|
|
291
|
-
|
|
292
|
-
│ hello.
|
|
293
|
-
|
|
328
|
+
┌─────────────────────────┬─────────────────────────────────────────────┐
|
|
329
|
+
│ Contract │ Artifact │
|
|
330
|
+
├─────────────────────────┼─────────────────────────────────────────────┤
|
|
331
|
+
│ hello.storageList.mligo │ artifacts/hello.default_storage.storage1.tz │
|
|
332
|
+
├─────────────────────────┼─────────────────────────────────────────────┤
|
|
333
|
+
│ hello.storageList.mligo │ artifacts/hello.storage.storage2.tz │
|
|
334
|
+
└─────────────────────────┴─────────────────────────────────────────────┘
|
|
294
335
|
versus
|
|
295
|
-
|
|
296
|
-
│ Contract
|
|
297
|
-
|
|
298
|
-
│ hello.
|
|
299
|
-
│
|
|
300
|
-
|
|
336
|
+
┌─────────────────────────┬─────────────────────────────────────────────┐
|
|
337
|
+
│ Contract │ Artifact │
|
|
338
|
+
├─────────────────────────┼─────────────────────────────────────────────┤
|
|
339
|
+
│ hello.storageList.mligo │ artifacts/hello.default_storage.storage1.tz │
|
|
340
|
+
│ │ artifacts/hello.storage.storage2.tz │
|
|
341
|
+
└─────────────────────────┴─────────────────────────────────────────────┘
|
|
301
342
|
*/ const $24b2f47d8f306cb3$var$mergeArtifactsOutput = (sourceFile)=>(tableRows)=>{
|
|
302
343
|
const artifactsOutput = tableRows.reduce((acc, row)=>row.artifact === $24b2f47d8f306cb3$var$COMPILE_ERR_MSG ? acc : `${acc}${row.artifact}\n`, "");
|
|
303
344
|
return [
|
|
@@ -310,8 +351,8 @@ e.g.
|
|
|
310
351
|
const $24b2f47d8f306cb3$var$compile = (parsedArgs)=>{
|
|
311
352
|
const sourceFile = parsedArgs.sourceFile;
|
|
312
353
|
let p;
|
|
313
|
-
if ($24b2f47d8f306cb3$var$
|
|
314
|
-
else if ($24b2f47d8f306cb3$var$
|
|
354
|
+
if ($24b2f47d8f306cb3$var$isStorageListFile(sourceFile)) p = $24b2f47d8f306cb3$var$compileExprs(parsedArgs, sourceFile, "storage");
|
|
355
|
+
else if ($24b2f47d8f306cb3$var$isParameterListFile(sourceFile)) p = $24b2f47d8f306cb3$var$compileExprs(parsedArgs, sourceFile, "parameter");
|
|
315
356
|
else if ($24b2f47d8f306cb3$var$isContractFile(sourceFile)) p = $24b2f47d8f306cb3$var$compileContractWithStorageAndParameter(parsedArgs, sourceFile);
|
|
316
357
|
else return (0, $kQNfl$taquerianodesdk.sendAsyncErr)(`${sourceFile} doesn't have a valid LIGO extension ('.ligo', '.religo', '.mligo' or '.jsligo')`);
|
|
317
358
|
return p.then((0, $kQNfl$taquerianodesdk.sendJsonRes)).catch((err)=>(0, $kQNfl$taquerianodesdk.sendAsyncErr)(err, false));
|
|
@@ -332,7 +373,7 @@ const $0be740342372c80a$var$getArbitraryLigoCmd = (parsedArgs, userArgs)=>{
|
|
|
332
373
|
`${projectDir}:/project`,
|
|
333
374
|
"-w",
|
|
334
375
|
"/project",
|
|
335
|
-
(0, $844cb58d66fbf6db$export$
|
|
376
|
+
(0, $844cb58d66fbf6db$export$2b403d61ac8ea302)()
|
|
336
377
|
];
|
|
337
378
|
const processedUserArgs = userArgs.split(" ").map((arg)=>arg.startsWith("\\-") ? arg.substring(1) : arg).filter((arg)=>arg);
|
|
338
379
|
const args = baseArgs.concat(processedUserArgs);
|
|
@@ -358,7 +399,7 @@ var $0be740342372c80a$export$2e2bcd8739ae039 = $0be740342372c80a$var$ligo;
|
|
|
358
399
|
const $8d09eb70c0505719$var$getTestContractCmd = (parsedArgs, sourceFile)=>{
|
|
359
400
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
360
401
|
if (!projectDir) throw `No project directory provided`;
|
|
361
|
-
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$
|
|
402
|
+
const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$2b403d61ac8ea302)()} run test`;
|
|
362
403
|
const inputFile = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile);
|
|
363
404
|
const cmd = `${baseCmd} ${inputFile}`;
|
|
364
405
|
return cmd;
|
|
@@ -371,8 +412,7 @@ const $8d09eb70c0505719$var$testContract = (parsedArgs, sourceFile)=>(0, $kQNfl$
|
|
|
371
412
|
testResults: stdout.length > 0 ? `${stdout}\n${result}` : result
|
|
372
413
|
};
|
|
373
414
|
}).catch((err)=>{
|
|
374
|
-
(0, $
|
|
375
|
-
(0, $kQNfl$taquerianodesdk.sendErr)(err.message.replace(/Command failed.+?\n/, ""));
|
|
415
|
+
(0, $844cb58d66fbf6db$export$b59ff90dc389ce6d)(err, sourceFile);
|
|
376
416
|
return {
|
|
377
417
|
contract: sourceFile,
|
|
378
418
|
testResults: "Some tests failed :("
|
|
@@ -395,6 +435,8 @@ const $9c25a106900e330c$var$main = (parsedArgs)=>{
|
|
|
395
435
|
return (0, $24b2f47d8f306cb3$export$2e2bcd8739ae039)(parsedArgs);
|
|
396
436
|
case "test":
|
|
397
437
|
return (0, $8d09eb70c0505719$export$2e2bcd8739ae039)(parsedArgs);
|
|
438
|
+
case "get-image":
|
|
439
|
+
return (0, $kQNfl$taquerianodesdk.sendAsyncRes)((0, $844cb58d66fbf6db$export$2b403d61ac8ea302)());
|
|
398
440
|
default:
|
|
399
441
|
return (0, $kQNfl$taquerianodesdk.sendAsyncErr)(`${parsedArgs.task} is not an understood task by the LIGO plugin`);
|
|
400
442
|
}
|
|
@@ -430,7 +472,7 @@ var $9c25a106900e330c$export$2e2bcd8739ae039 = $9c25a106900e330c$var$main;
|
|
|
430
472
|
"c",
|
|
431
473
|
"compile-ligo"
|
|
432
474
|
],
|
|
433
|
-
description: "Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated
|
|
475
|
+
description: "Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found",
|
|
434
476
|
handler: "proxy",
|
|
435
477
|
encoding: "json"
|
|
436
478
|
}),
|
|
@@ -440,6 +482,13 @@ var $9c25a106900e330c$export$2e2bcd8739ae039 = $9c25a106900e330c$var$main;
|
|
|
440
482
|
description: "Test a smart contract written in LIGO",
|
|
441
483
|
handler: "proxy",
|
|
442
484
|
encoding: "json"
|
|
485
|
+
}),
|
|
486
|
+
(0, $kQNfl$taquerianodesdk.Task).create({
|
|
487
|
+
task: "get-image",
|
|
488
|
+
command: "get-image",
|
|
489
|
+
description: "Gets the name of the image to be used",
|
|
490
|
+
handler: "proxy",
|
|
491
|
+
hidden: true
|
|
443
492
|
}),
|
|
444
493
|
],
|
|
445
494
|
templates: [
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;ACAA;;ACAO,MAAM,yCAAc,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAwB/B,CAAC,AAAC;AAEK,MAAM,yCAAkB,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BnC,CAAC,AAAC;AAEK,MAAM,yCAAe,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBhC,CAAC,AAAC;AAEK,MAAM,yCAAe,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBhC,CAAC,AAAC;;;ADlGF,MAAM,sCAAgB,GAAG,CAAC,GAAS,EAAE,YAAoB,GAAK;IAC7D,CAAA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,wCAAc,CAAA;aACvB,CAAC;SACF;QACD,KAAK,EAAE,CAAA,GAAA,wCAAI,CAAA;KACX,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-ligo/index.ts","taqueria-plugin-ligo/createContract.ts","taqueria-plugin-ligo/ligo_templates.ts","taqueria-plugin-ligo/main.ts","taqueria-plugin-ligo/compile.ts","taqueria-plugin-ligo/common.ts","taqueria-plugin-ligo/ligo.ts","taqueria-plugin-ligo/test.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport createContract from './createContract';\nimport main from './main';\n\nPlugin.create(i18n => ({\n\tschema: '1.0',\n\tversion: '0.1',\n\talias: 'ligo',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'ligo',\n\t\t\tcommand: 'ligo',\n\t\t\tdescription:\n\t\t\t\t'This task allows you to run arbitrary LIGO 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 LIGO 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: 'compile',\n\t\t\tcommand: 'compile <sourceFile>',\n\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\tdescription:\n\t\t\t\t'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storages and parameters files if they are found',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test <sourceFile>',\n\t\t\tdescription: 'Test a smart contract written in LIGO',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'contract',\n\t\t\tcommand: 'contract <sourceFileName>',\n\t\t\tdescription: 'Create a LIGO contract with boilerplate code',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The name of the LIGO contract to generate',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 's',\n\t\t\t\t\tflag: 'syntax',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The syntax used in the contract',\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: createContract,\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { experimental, sendAsyncErr } from '@taqueria/node-sdk';\nimport * as RequestArgs from '@taqueria/protocol/RequestArgs';\nimport { writeFile } from 'fs/promises';\nimport { jsligo_template, mligo_template, pascaligo_template, religo_template } from './ligo_templates';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n\tsyntax?: string;\n}\n\nconst registerContract = (arg: Opts, contractName: string) => {\n\texperimental.registerContract(arg, contractName);\n};\n\nconst getLigoTemplate = async (contractName: string, syntax: string | undefined): Promise<string> => {\n\tconst matchResult = contractName.match(/\\.[^.]+$/);\n\tconst ext = matchResult ? matchResult[0].substring(1) : null;\n\n\tif (syntax === 'mligo') return mligo_template;\n\tif (syntax === 'ligo') return pascaligo_template;\n\tif (syntax === 'religo') return religo_template;\n\tif (syntax === 'jsligo') return jsligo_template;\n\n\tif (syntax === undefined) {\n\t\tif (ext === 'mligo') return mligo_template;\n\t\tif (ext === 'ligo') return pascaligo_template;\n\t\tif (ext === 'religo') return religo_template;\n\t\tif (ext === 'jsligo') return jsligo_template;\n\t\treturn sendAsyncErr(\n\t\t\t`Unable to infer LIGO syntax from \"${contractName}\". Please specify a LIGO syntax via the --syntax option`,\n\t\t);\n\t} else {\n\t\treturn sendAsyncErr(`\"${syntax}\" is not a valid syntax. Please specify a valid LIGO syntax`);\n\t}\n};\n\nconst createContract = (arg: Opts) => {\n\tconst contractName = arg.sourceFileName as string;\n\tconst syntax = arg.syntax;\n\tconst contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;\n\treturn getLigoTemplate(contractName, syntax)\n\t\t.then(ligo_template => writeFile(`${contractsDir}/${contractName}`, ligo_template))\n\t\t.then(_ => registerContract(arg, contractName));\n};\n\nexport default createContract;\n","export const mligo_template = `\ntype storage = int\n\ntype parameter =\n Increment of int\n| Decrement of int\n| Reset\n\ntype return = operation list * storage\n\n// Two entrypoints\n\nlet add (store, delta : storage * int) : storage = store + delta\nlet sub (store, delta : storage * int) : storage = store - delta\n\n(* Main access point that dispatches to the entrypoints according to\n the smart contract parameter. *)\n \nlet main (action, store : parameter * storage) : return =\n ([] : operation list), // No operations\n (match action with\n Increment (n) -> add (store, n)\n | Decrement (n) -> sub (store, n)\n | Reset -> 0)\n`;\n\nexport const pascaligo_template = `\ntype storage is int\n\ntype parameter is\n Increment of int\n| Decrement of int\n| Reset\n\ntype return is list (operation) * storage\n\n// Two entrypoints\n\nfunction add (const store : storage; const delta : int) : storage is \n store + delta\n\nfunction sub (const store : storage; const delta : int) : storage is \n store - delta\n\n(* Main access point that dispatches to the entrypoints according to\n the smart contract parameter. *)\n \nfunction main (const action : parameter; const store : storage) : return is\n ((nil : list (operation)), // No operations\n case action of [\n Increment (n) -> add (store, n)\n | Decrement (n) -> sub (store, n)\n | Reset -> 0\n ])\n`;\n\nexport const religo_template = `\ntype storage = int;\n\ntype parameter =\n Increment (int)\n| Decrement (int)\n| Reset;\n\ntype return = (list (operation), storage);\n\n// Two entrypoints\n\nlet add = ((store, delta) : (storage, int)) : storage => store + delta;\nlet sub = ((store, delta) : (storage, int)) : storage => store - delta;\n\n/* Main access point that dispatches to the entrypoints according to\n the smart contract parameter. */\n \nlet main = ((action, store) : (parameter, storage)) : return => {\n (([] : list (operation)), // No operations\n (switch (action) {\n | Increment (n) => add ((store, n))\n | Decrement (n) => sub ((store, n))\n | Reset => 0}))\n};\n`;\n\nexport const jsligo_template = `\ntype storage = int;\n\ntype parameter =\n [\"Increment\", int]\n| [\"Decrement\", int]\n| [\"Reset\"];\n\ntype ret = [list<operation>, storage];\n\n// Two entrypoints\n\nconst add = ([store, delta] : [storage, int]) : storage => store + delta;\nconst sub = ([store, delta] : [storage, int]) : storage => store - delta;\n\n/* Main access point that dispatches to the entrypoints according to\n the smart contract parameter. */\n\nconst main = ([action, store] : [parameter, storage]) : ret => {\n return [list([]) as list<operation>, // No operations\n match (action, {\n Increment:(n: int) => add ([store, n]),\n Decrement:(n: int) => sub ([store, n]),\n Reset :() => 0})]\n};\n`;\n","import { sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport ligo from './ligo';\nimport test from './test';\n\nconst main = (parsedArgs: Opts): Promise<void> => {\n\tswitch (parsedArgs.task) {\n\t\tcase 'ligo':\n\t\t\treturn ligo(parsedArgs);\n\t\tcase 'compile':\n\t\t\treturn compile(parsedArgs);\n\t\tcase 'test':\n\t\t\treturn test(parsedArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${parsedArgs.task} is not an understood task by the LIGO plugin`);\n\t}\n};\n\nexport default main;\n","import { execCmd, getArch, sendAsyncErr, sendErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { access, readFile, writeFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport { CompileOpts as Opts, getInputFilename, LIGO_DOCKER_IMAGE } from './common';\n\ntype TableRow = { contract: string; artifact: string };\n\ntype ExprKind = 'storage' | 'default_storage' | 'parameter';\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isStorageKind = (exprKind: ExprKind): boolean => exprKind === 'storage' || exprKind === 'default_storage';\n\nconst isLIGOFile = (sourceFile: string): boolean => /.+\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst isStoragesFile = (sourceFile: string): boolean => /.+\\.storages\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst isParametersFile = (sourceFile: string): boolean =>\n\t/.+\\.parameters\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst isContractFile = (sourceFile: string): boolean =>\n\tisLIGOFile(sourceFile) && !isStoragesFile(sourceFile) && !isParametersFile(sourceFile);\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.(ligo|religo|mligo|jsligo)$/);\n\treturn matchResult ? matchResult[0] : '';\n};\n\nconst removeExt = (path: string): string => {\n\tconst extRegex = new RegExp(extractExt(path));\n\treturn path.replace(extRegex, '');\n};\n\nconst getOutputFilename = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\treturn join(parsedArgs.config.artifactsDir, `${outputFile}.tz`);\n};\n\n// Get the contract name that the storage/parameter file is associated with\n// e.g. If sourceFile is token.storages.mligo, then it'll return token.mligo\nconst getContractNameForExpr = (sourceFile: string, exprKind: ExprKind): string => {\n\ttry {\n\t\treturn isStorageKind(exprKind)\n\t\t\t? sourceFile.match(/.+(?=\\.storages\\.(ligo|religo|mligo|jsligo))/)!.join('.')\n\t\t\t: sourceFile.match(/.+(?=\\.parameters\\.(ligo|religo|mligo|jsligo))/)!.join('.');\n\t} catch (err) {\n\t\tthrow new Error(`Something went wrong internally when dealing with filename format: ${err}`);\n\t}\n};\n\n// If sourceFile is token.storages.mligo, then it'll return token.storage.{storageName}.tz\nconst getOutputExprFileName = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind, exprName: string): string => {\n\tconst contractName = basename(getContractNameForExpr(sourceFile, exprKind), extname(sourceFile));\n\tconst outputFile = exprKind === 'default_storage'\n\t\t? `${contractName}.default_storage.tz`\n\t\t: `${contractName}.${exprKind}.${exprName}.tz`;\n\treturn join(parsedArgs.config.artifactsDir, `${outputFile}`);\n};\n\nconst getCompileContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst baseCmd =\n\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${LIGO_DOCKER_IMAGE} compile contract`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst outputFile = `-o ${getOutputFilename(parsedArgs, sourceFile)}`;\n\tconst cmd = `${baseCmd} ${inputFile} ${outputFile}`;\n\treturn cmd;\n};\n\nconst getCompileExprCmd = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind, exprName: string): string => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst compilerType = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\tconst baseCmd =\n\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${LIGO_DOCKER_IMAGE} compile ${compilerType}`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst outputFile = `-o ${getOutputExprFileName(parsedArgs, sourceFile, exprKind, exprName)}`;\n\tconst cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile}`;\n\treturn cmd;\n};\n\nconst compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => getCompileContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: getOutputFilename(parsedArgs, sourceFile),\n\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\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t});\n\nconst compileExpr = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind) =>\n\t(exprName: string): Promise<TableRow> =>\n\t\tgetArch()\n\t\t\t.then(() => getCompileExprCmd(parsedArgs, sourceFile, exprKind, exprName))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stderr }) => {\n\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: getOutputExprFileName(parsedArgs, sourceFile, exprKind, exprName),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\tsendErr(`\\n=== For ${sourceFile} ===`);\n\t\t\t\tsendErr(err.message.replace(/Command failed.+?\\n/, ''));\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t\t};\n\t\t\t});\n\nconst compileExprs = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind): Promise<TableRow[]> =>\n\treadFile(getInputFilename(parsedArgs, sourceFile), 'utf8')\n\t\t.then(async data => {\n\t\t\tif (!data.includes('#include')) {\n\t\t\t\tawait writeFile(\n\t\t\t\t\tgetInputFilename(parsedArgs, sourceFile),\n\t\t\t\t\t`#include \"${getContractNameForExpr(sourceFile, exprKind)}\"\\n` + data,\n\t\t\t\t\t'utf8',\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn data;\n\t\t})\n\t\t.then(data => data.match(/(?<=\\s*(let|const)\\s+)[a-zA-Z0-9_]+/g))\n\t\t.then(exprNames => {\n\t\t\tif (!exprNames) return [];\n\t\t\tconst firstExprName = exprNames.slice(0, 1)[0];\n\t\t\tconst restExprNames = exprNames.slice(1, exprNames.length);\n\t\t\tconst firstExprKind = isStorageKind(exprKind) ? 'default_storage' : 'parameter';\n\t\t\tconst restExprKind = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\t\t\tconst firstExprResult = compileExpr(parsedArgs, sourceFile, firstExprKind)(firstExprName);\n\t\t\tconst restExprResults = restExprNames.map(compileExpr(parsedArgs, sourceFile, restExprKind));\n\t\t\treturn Promise.all([firstExprResult].concat(restExprResults));\n\t\t})\n\t\t.catch(err => {\n\t\t\tsendErr(`\\n=== For ${sourceFile} ===`);\n\t\t\tsendErr(err.message);\n\t\t\treturn [{\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: `No ${isStorageKind(exprKind) ? 'storages' : 'parameters'} compiled`,\n\t\t\t}];\n\t\t})\n\t\t.then(mergeArtifactsOutput(sourceFile));\n\nconst compileContractWithStorageAndParameter = async (parsedArgs: Opts, sourceFile: string): Promise<TableRow[]> => {\n\tconst contractCompileResult = await compileContract(parsedArgs, sourceFile);\n\tif (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];\n\n\tconst storagesFile = `${removeExt(sourceFile)}.storages${extractExt(sourceFile)}`;\n\tconst parametersFile = `${removeExt(sourceFile)}.parameters${extractExt(sourceFile)}`;\n\tconst storagesFilename = getInputFilename(parsedArgs, storagesFile);\n\tconst parametersFilename = getInputFilename(parsedArgs, parametersFile);\n\n\tconst storageCompileResult = await access(storagesFilename)\n\t\t.then(() => compileExprs(parsedArgs, storagesFile, 'storage'))\n\t\t.catch(() => {\n\t\t\t// sendWarn(\n\t\t\t// \t`Note: storage file associated with \"${sourceFile}\" can't be found. You should create a file \"${storagesFile}\" and define initial storage values as a list of LIGO variable definitions. e.g. \"let STORAGE_NAME: storage = LIGO_EXPR\" for CameLigo`,\n\t\t\t// )\n\t\t});\n\n\tconst parameterCompileResult = await access(parametersFilename)\n\t\t.then(() => compileExprs(parsedArgs, parametersFile, 'parameter'))\n\t\t.catch(() => {\n\t\t\t// sendWarn(\n\t\t\t// \t`Note: parameter file associated with \"${sourceFile}\" can't be found. You should create a file \"${parametersFile}\" and define parameter values as a list of LIGO variable definitions. e.g. \"let PARAMETER_NAME: parameter = LIGO_EXPR\" for CameLigo`,\n\t\t\t// )\n\t\t});\n\n\tlet compileResults: TableRow[] = [contractCompileResult];\n\tif (storageCompileResult) compileResults = compileResults.concat(storageCompileResult);\n\tif (parameterCompileResult) compileResults = compileResults.concat(parameterCompileResult);\n\treturn compileResults;\n};\n\n/*\nCompiling storage/parameter file amounts to compiling multiple expressions in that file,\nresulting in multiple rows with the same file name but different artifact names.\nThis will merge these rows into one row with just one mention of the file name.\ne.g.\n┌──────────────────────┬─────────────────────────────────────────────┐\n│ Contract │ Artifact │\n├──────────────────────┼─────────────────────────────────────────────┤\n│ hello.storages.mligo │ artifacts/hello.default_storage.storage1.tz │\n├──────────────────────┼─────────────────────────────────────────────┤\n│ hello.storages.mligo │ artifacts/hello.storage.storage2.tz │\n└──────────────────────┴─────────────────────────────────────────────┘\n\t\t\t\t\t\t\t\tversus\n┌──────────────────────┬─────────────────────────────────────────────┐\n│ Contract │ Artifact │\n├──────────────────────┼─────────────────────────────────────────────┤\n│ hello.storages.mligo │ artifacts/hello.default_storage.storage1.tz │\n│ │ artifacts/hello.storage.storage2.tz │\n└──────────────────────┴─────────────────────────────────────────────┘\n*/\nconst mergeArtifactsOutput = (sourceFile: string) =>\n\t(tableRows: TableRow[]): TableRow[] => {\n\t\tconst artifactsOutput = tableRows.reduce(\n\t\t\t(acc: string, row: TableRow) => row.artifact === COMPILE_ERR_MSG ? acc : `${acc}${row.artifact}\\n`,\n\t\t\t'',\n\t\t);\n\t\treturn [{\n\t\t\tcontract: sourceFile,\n\t\t\tartifact: artifactsOutput,\n\t\t}];\n\t};\n\nconst compile = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = parsedArgs.sourceFile;\n\tlet p: Promise<TableRow[]>;\n\tif (isStoragesFile(sourceFile)) p = compileExprs(parsedArgs, sourceFile, 'storage');\n\telse if (isParametersFile(sourceFile)) p = compileExprs(parsedArgs, sourceFile, 'parameter');\n\telse if (isContractFile(sourceFile)) p = compileContractWithStorageAndParameter(parsedArgs, sourceFile);\n\telse {\n\t\treturn sendAsyncErr(\n\t\t\t`${sourceFile} doesn't have a valid LIGO extension ('.ligo', '.religo', '.mligo' or '.jsligo')`,\n\t\t);\n\t}\n\treturn p.then(sendJsonRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default compile;\n","import { RequestArgs } from '@taqueria/node-sdk/types';\nimport { join } from 'path';\n\nexport interface LigoOpts extends RequestArgs.ProxyRequestArgs {\n\tcommand: string;\n}\n\nexport interface CompileOpts extends RequestArgs.ProxyRequestArgs {\n\tsourceFile: string;\n}\n\nexport interface TestOpts extends RequestArgs.ProxyRequestArgs {\n\tsourceFile: string;\n}\n\nexport type IntersectionOpts = LigoOpts & CompileOpts & TestOpts;\n\ntype UnionOpts = LigoOpts | CompileOpts | TestOpts;\n\n// Points to the latest stable version. Needs to update this as part of our release process\nexport const LIGO_DOCKER_IMAGE = 'ligolang/ligo:0.55.0';\n\nexport const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.contractsDir, sourceFile);\n","import { CmdArgEnv, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';\nimport { LIGO_DOCKER_IMAGE, LigoOpts as Opts } from './common';\n\nconst getArbitraryLigoCmd = (parsedArgs: Opts, userArgs: string): CmdArgEnv => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst binary = 'docker';\n\tconst baseArgs = ['run', '--rm', '-v', `${projectDir}:/project`, '-w', '/project', LIGO_DOCKER_IMAGE];\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 = { 'DOCKER_DEFAULT_PLATFORM': 'linux/amd64' };\n\treturn [binary, args, envVars];\n};\n\nconst runArbitraryLigoCmd = (parsedArgs: Opts, cmd: string): Promise<string> =>\n\tgetArch()\n\t\t.then(() => getArbitraryLigoCmd(parsedArgs, cmd))\n\t\t.then(spawnCmd)\n\t\t.then(code =>\n\t\t\tcode !== null && code === 0\n\t\t\t\t? `Command \"${cmd}\" ran successfully by LIGO`\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 ligo = (parsedArgs: Opts): Promise<void> => {\n\tconst args = parsedArgs.command;\n\treturn runArbitraryLigoCmd(parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default ligo;\n","import { execCmd, getArch, sendAsyncErr, sendErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { getInputFilename, LIGO_DOCKER_IMAGE, TestOpts as Opts } from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst baseCmd =\n\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${LIGO_DOCKER_IMAGE} run test`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst cmd = `${baseCmd} ${inputFile}`;\n\treturn cmd;\n};\n\nconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stdout, stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\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\ttestResults: 'Some tests failed :(',\n\t\t\t};\n\t\t});\n\nconst test = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = parsedArgs.sourceFile;\n\treturn testContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default test;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":";;;;AAAA;ACAA;;ACAO,MAAM,yCAAc,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAwB/B,CAAC,AAAC;AAEK,MAAM,yCAAkB,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BnC,CAAC,AAAC;AAEK,MAAM,yCAAe,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBhC,CAAC,AAAC;AAEK,MAAM,yCAAe,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBhC,CAAC,AAAC;;;ADlGF,MAAM,sCAAgB,GAAG,CAAC,GAAS,EAAE,YAAoB,GAAK;IAC7D,CAAA,GAAA,mCAAY,CAAA,CAAC,gBAAgB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;CACjD,AAAC;AAEF,MAAM,qCAAe,GAAG,OAAO,YAAoB,EAAE,MAA0B,GAAsB;IACpG,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,YAAY,AAAC;IACnD,MAAM,GAAG,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,AAAC;IAE7D,IAAI,MAAM,KAAK,OAAO,EAAE,OAAO,GAAA,yCAAc,CAAC;IAC9C,IAAI,MAAM,KAAK,MAAM,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AI,CAAC,CAAC","sources":["taqueria-plugin-ligo/index.ts","taqueria-plugin-ligo/createContract.ts","taqueria-plugin-ligo/ligo_templates.ts","taqueria-plugin-ligo/main.ts","taqueria-plugin-ligo/common.ts","taqueria-plugin-ligo/compile.ts","taqueria-plugin-ligo/ligo.ts","taqueria-plugin-ligo/test.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport createContract from './createContract';\nimport main from './main';\n\nPlugin.create(i18n => ({\n\tschema: '1.0',\n\tversion: '0.1',\n\talias: 'ligo',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'ligo',\n\t\t\tcommand: 'ligo',\n\t\t\tdescription:\n\t\t\t\t'This task allows you to run arbitrary LIGO 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 LIGO 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: 'compile',\n\t\t\tcommand: 'compile <sourceFile>',\n\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\tdescription:\n\t\t\t\t'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test <sourceFile>',\n\t\t\tdescription: 'Test a smart contract written in LIGO',\n\t\t\thandler: 'proxy',\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\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'contract',\n\t\t\tcommand: 'contract <sourceFileName>',\n\t\t\tdescription: 'Create a LIGO contract with boilerplate code',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The name of the LIGO contract to generate',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 's',\n\t\t\t\t\tflag: 'syntax',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The syntax used in the contract',\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: createContract,\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { experimental, sendAsyncErr } from '@taqueria/node-sdk';\nimport * as RequestArgs from '@taqueria/protocol/RequestArgs';\nimport { writeFile } from 'fs/promises';\nimport { jsligo_template, mligo_template, pascaligo_template, religo_template } from './ligo_templates';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n\tsyntax?: string;\n}\n\nconst registerContract = (arg: Opts, contractName: string) => {\n\texperimental.registerContract(arg, contractName);\n};\n\nconst getLigoTemplate = async (contractName: string, syntax: string | undefined): Promise<string> => {\n\tconst matchResult = contractName.match(/\\.[^.]+$/);\n\tconst ext = matchResult ? matchResult[0].substring(1) : null;\n\n\tif (syntax === 'mligo') return mligo_template;\n\tif (syntax === 'ligo') return pascaligo_template;\n\tif (syntax === 'religo') return religo_template;\n\tif (syntax === 'jsligo') return jsligo_template;\n\n\tif (syntax === undefined) {\n\t\tif (ext === 'mligo') return mligo_template;\n\t\tif (ext === 'ligo') return pascaligo_template;\n\t\tif (ext === 'religo') return religo_template;\n\t\tif (ext === 'jsligo') return jsligo_template;\n\t\treturn sendAsyncErr(\n\t\t\t`Unable to infer LIGO syntax from \"${contractName}\". Please specify a LIGO syntax via the --syntax option`,\n\t\t);\n\t} else {\n\t\treturn sendAsyncErr(`\"${syntax}\" is not a valid syntax. Please specify a valid LIGO syntax`);\n\t}\n};\n\nconst createContract = (arg: Opts) => {\n\tconst contractName = arg.sourceFileName as string;\n\tconst syntax = arg.syntax;\n\tconst contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;\n\treturn getLigoTemplate(contractName, syntax)\n\t\t.then(ligo_template => writeFile(`${contractsDir}/${contractName}`, ligo_template))\n\t\t.then(_ => registerContract(arg, contractName));\n};\n\nexport default createContract;\n","export const mligo_template = `\ntype storage = int\n\ntype parameter =\n Increment of int\n| Decrement of int\n| Reset\n\ntype return = operation list * storage\n\n// Two entrypoints\n\nlet add (store, delta : storage * int) : storage = store + delta\nlet sub (store, delta : storage * int) : storage = store - delta\n\n(* Main access point that dispatches to the entrypoints according to\n the smart contract parameter. *)\n \nlet main (action, store : parameter * storage) : return =\n ([] : operation list), // No operations\n (match action with\n Increment (n) -> add (store, n)\n | Decrement (n) -> sub (store, n)\n | Reset -> 0)\n`;\n\nexport const pascaligo_template = `\ntype storage is int\n\ntype parameter is\n Increment of int\n| Decrement of int\n| Reset\n\ntype return is list (operation) * storage\n\n// Two entrypoints\n\nfunction add (const store : storage; const delta : int) : storage is \n store + delta\n\nfunction sub (const store : storage; const delta : int) : storage is \n store - delta\n\n(* Main access point that dispatches to the entrypoints according to\n the smart contract parameter. *)\n \nfunction main (const action : parameter; const store : storage) : return is\n ((nil : list (operation)), // No operations\n case action of [\n Increment (n) -> add (store, n)\n | Decrement (n) -> sub (store, n)\n | Reset -> 0\n ])\n`;\n\nexport const religo_template = `\ntype storage = int;\n\ntype parameter =\n Increment (int)\n| Decrement (int)\n| Reset;\n\ntype return = (list (operation), storage);\n\n// Two entrypoints\n\nlet add = ((store, delta) : (storage, int)) : storage => store + delta;\nlet sub = ((store, delta) : (storage, int)) : storage => store - delta;\n\n/* Main access point that dispatches to the entrypoints according to\n the smart contract parameter. */\n \nlet main = ((action, store) : (parameter, storage)) : return => {\n (([] : list (operation)), // No operations\n (switch (action) {\n | Increment (n) => add ((store, n))\n | Decrement (n) => sub ((store, n))\n | Reset => 0}))\n};\n`;\n\nexport const jsligo_template = `\ntype storage = int;\n\ntype parameter =\n [\"Increment\", int]\n| [\"Decrement\", int]\n| [\"Reset\"];\n\ntype ret = [list<operation>, storage];\n\n// Two entrypoints\n\nconst add = ([store, delta] : [storage, int]) : storage => store + delta;\nconst sub = ([store, delta] : [storage, int]) : storage => store - delta;\n\n/* Main access point that dispatches to the entrypoints according to\n the smart contract parameter. */\n\nconst main = ([action, store] : [parameter, storage]) : ret => {\n return [list([]) as list<operation>, // No operations\n match (action, {\n Increment:(n: int) => add ([store, n]),\n Decrement:(n: int) => sub ([store, n]),\n Reset :() => 0})]\n};\n`;\n","import { sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { getLigoDockerImage, IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport ligo from './ligo';\nimport test from './test';\n\nconst main = (parsedArgs: Opts): Promise<void> => {\n\tswitch (parsedArgs.task) {\n\t\tcase 'ligo':\n\t\t\treturn ligo(parsedArgs);\n\t\tcase 'compile':\n\t\t\treturn compile(parsedArgs);\n\t\tcase 'test':\n\t\t\treturn test(parsedArgs);\n\t\tcase 'get-image':\n\t\t\treturn sendAsyncRes(getLigoDockerImage());\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${parsedArgs.task} is not an understood task by the LIGO plugin`);\n\t}\n};\n\nexport default main;\n","import { getDockerImage, sendErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk/types';\nimport { join } from 'path';\n\nexport interface LigoOpts extends RequestArgs.ProxyRequestArgs {\n\tcommand: string;\n}\n\nexport interface CompileOpts extends RequestArgs.ProxyRequestArgs {\n\tsourceFile: string;\n}\n\nexport interface TestOpts extends RequestArgs.ProxyRequestArgs {\n\tsourceFile: string;\n}\n\nexport type IntersectionOpts = LigoOpts & CompileOpts & TestOpts;\n\ntype UnionOpts = LigoOpts | CompileOpts | TestOpts;\n\n// Should point to the latest stable version, so it needs to be updated as part of our release process.\nconst LIGO_DEFAULT_IMAGE = 'ligolang/ligo:0.54.1';\n\nconst LIGO_IMAGE_ENV_VAR = 'TAQ_LIGO_IMAGE';\n\nexport const getLigoDockerImage = (): string => getDockerImage(LIGO_DEFAULT_IMAGE, LIGO_IMAGE_ENV_VAR);\n\nexport const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.contractsDir, sourceFile);\n\nexport const emitExternalError = (err: unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== For ${sourceFile} ===`);\n\terr instanceof Error ? sendErr(err.message.replace(/Command failed.+?\\n/, '')) : sendErr(err as any);\n};\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { access, readFile, writeFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport { CompileOpts as Opts, emitExternalError, getInputFilename, getLigoDockerImage } from './common';\n\ntype TableRow = { contract: string; artifact: string };\n\ntype ExprKind = 'storage' | 'default_storage' | 'parameter';\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isStorageKind = (exprKind: ExprKind): boolean => exprKind === 'storage' || exprKind === 'default_storage';\n\nconst isLIGOFile = (sourceFile: string): boolean => /.+\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst isStorageListFile = (sourceFile: string): boolean =>\n\t/.+\\.(storageList|storages)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst isParameterListFile = (sourceFile: string): boolean =>\n\t/.+\\.(parameterList|parameters)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst isContractFile = (sourceFile: string): boolean =>\n\tisLIGOFile(sourceFile) && !isStorageListFile(sourceFile) && !isParameterListFile(sourceFile);\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.(ligo|religo|mligo|jsligo)$/);\n\treturn matchResult ? matchResult[0] : '';\n};\n\nconst removeExt = (path: string): string => {\n\tconst extRegex = new RegExp(extractExt(path));\n\treturn path.replace(extRegex, '');\n};\n\nconst getOutputFilename = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\treturn join(parsedArgs.config.artifactsDir, `${outputFile}.tz`);\n};\n\n// Get the contract name that the storage/parameter file is associated with\n// e.g. If sourceFile is token.storageList.mligo, then it'll return token.mligo\nconst getContractNameForExpr = (sourceFile: string, exprKind: ExprKind): string => {\n\ttry {\n\t\treturn isStorageKind(exprKind)\n\t\t\t? sourceFile.match(/.+(?=\\.(?:storageList|storages)\\.(ligo|religo|mligo|jsligo))/)!.join('.')\n\t\t\t: sourceFile.match(/.+(?=\\.(?:parameterList|parameters)\\.(ligo|religo|mligo|jsligo))/)!.join('.');\n\t} catch (err) {\n\t\tthrow new Error(`Something went wrong internally when dealing with filename format: ${err}`);\n\t}\n};\n\n// If sourceFile is token.storageList.mligo, then it'll return token.storage.{storageName}.tz\nconst getOutputExprFileName = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind, exprName: string): string => {\n\tconst contractName = basename(getContractNameForExpr(sourceFile, exprKind), extname(sourceFile));\n\tconst outputFile = exprKind === 'default_storage'\n\t\t? `${contractName}.default_storage.tz`\n\t\t: `${contractName}.${exprKind}.${exprName}.tz`;\n\treturn join(parsedArgs.config.artifactsDir, `${outputFile}`);\n};\n\nconst getCompileContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst baseCmd =\n\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst outputFile = `-o ${getOutputFilename(parsedArgs, sourceFile)}`;\n\tconst cmd = `${baseCmd} ${inputFile} ${outputFile}`;\n\treturn cmd;\n};\n\nconst getCompileExprCmd = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind, exprName: string): string => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst compilerType = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\tconst baseCmd =\n\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst outputFile = `-o ${getOutputExprFileName(parsedArgs, sourceFile, exprKind, exprName)}`;\n\tconst cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile}`;\n\treturn cmd;\n};\n\nconst compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => getCompileContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: getOutputFilename(parsedArgs, sourceFile),\n\t\t\t};\n\t\t})\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t});\n\nconst compileExpr = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind) =>\n\t(exprName: string): Promise<TableRow> =>\n\t\tgetArch()\n\t\t\t.then(() => getCompileExprCmd(parsedArgs, sourceFile, exprKind, exprName))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stderr }) => {\n\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: getOutputExprFileName(parsedArgs, sourceFile, exprKind, exprName),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\temitExternalError(err, sourceFile);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t\t};\n\t\t\t});\n\nconst compileExprs = (parsedArgs: Opts, sourceFile: string, exprKind: ExprKind): Promise<TableRow[]> =>\n\treadFile(getInputFilename(parsedArgs, sourceFile), 'utf8')\n\t\t.then(data => data.match(/(?<=\\n\\s*(let|const)\\s+)[a-zA-Z0-9_]+/g))\n\t\t.then(exprNames => {\n\t\t\tif (!exprNames) return [];\n\t\t\tconst firstExprName = exprNames.slice(0, 1)[0];\n\t\t\tconst restExprNames = exprNames.slice(1, exprNames.length);\n\t\t\tconst firstExprKind = isStorageKind(exprKind) ? 'default_storage' : 'parameter';\n\t\t\tconst restExprKind = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\t\t\tconst firstExprResult = compileExpr(parsedArgs, sourceFile, firstExprKind)(firstExprName);\n\t\t\tconst restExprResults = restExprNames.map(compileExpr(parsedArgs, sourceFile, restExprKind));\n\t\t\treturn Promise.all([firstExprResult].concat(restExprResults));\n\t\t})\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [{\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: `No ${isStorageKind(exprKind) ? 'storage' : 'parameter'} values compiled`,\n\t\t\t}];\n\t\t})\n\t\t.then(mergeArtifactsOutput(sourceFile));\n\n// TODO: Just for backwards compatibility. Can be deleted in the future.\nconst tryLegacyStorageNamingConvention = (parsedArgs: Opts, sourceFile: string) => {\n\tconst storageListFile = `${removeExt(sourceFile)}.storages${extractExt(sourceFile)}`;\n\tconst storageListFilename = getInputFilename(parsedArgs, storageListFile);\n\treturn access(storageListFilename).then(() => {\n\t\tsendWarn(\n\t\t\t`Warning: The naming convention of \"<CONTRACT>.storages.<EXTENSION>\" is deprecated and renamed to \"<CONTRACT>.storageList.<EXTENSION>\". Please adjust your storage file names accordingly\\n`,\n\t\t);\n\t\treturn compileExprs(parsedArgs, storageListFile, 'storage');\n\t});\n};\n\n// TODO: Just for backwards compatibility. Can be deleted in the future.\nconst tryLegacyParameterNamingConvention = (parsedArgs: Opts, sourceFile: string) => {\n\tconst parameterListFile = `${removeExt(sourceFile)}.parameters${extractExt(sourceFile)}`;\n\tconst parameterListFilename = getInputFilename(parsedArgs, parameterListFile);\n\treturn access(parameterListFilename).then(() => {\n\t\tsendWarn(\n\t\t\t`Warning: The naming convention of \"<CONTRACT>.parameters.<EXTENSION>\" is deprecated and renamed to \"<CONTRACT>.parameterList.<EXTENSION>\". Please adjust your parameter file names accordingly\\n`,\n\t\t);\n\t\treturn compileExprs(parsedArgs, parameterListFile, 'parameter');\n\t});\n};\n\nconst initContentForStorage = (sourceFile: string): string => {\n\tconst linkToContract = `#include \"${sourceFile}\"\\n\\n`;\n\n\tconst instruction =\n\t\t'// Define your initial storage values as a list of LIGO variable definitions,\\n// the first of which will be considered the default value to be used for origination later on\\n';\n\n\tconst ext = extractExt(sourceFile);\n\tlet syntax = '';\n\tif (ext === '.ligo') syntax = '// E.g. const aStorageValue : aStorageType = 10;\\n\\n';\n\telse if (ext === '.religo') syntax = '// E.g. let aStorageValue : aStorageType = 10;\\n\\n';\n\telse if (ext === '.mligo') syntax = '// E.g. let aStorageValue : aStorageType = 10\\n\\n';\n\telse if (ext === '.jsligo') syntax = '// E.g. const aStorageValue : aStorageType = 10;\\n\\n';\n\n\treturn linkToContract + instruction + syntax;\n};\n\nconst initContentForParameter = (sourceFile: string): string => {\n\tconst linkToContract = `#include \"${sourceFile}\"\\n\\n`;\n\n\tconst instruction = '// Define your parameter values as a list of LIGO variable definitions\\n';\n\n\tconst ext = extractExt(sourceFile);\n\tlet syntax = '';\n\tif (ext === '.ligo') syntax = '// E.g. const aParameterValue : aParameterType = Increment(1);\\n\\n';\n\telse if (ext === '.religo') syntax = '// E.g. let aParameterValue : aParameterType = (Increment (1));\\n\\n';\n\telse if (ext === '.mligo') syntax = '// E.g. let aParameterValue : aParameterType = Increment 1\\n\\n';\n\telse if (ext === '.jsligo') syntax = '// E.g. const aParameterValue : aParameterType = (Increment (1));\\n\\n';\n\n\treturn linkToContract + instruction + syntax;\n};\n\nconst compileContractWithStorageAndParameter = async (parsedArgs: Opts, sourceFile: string): Promise<TableRow[]> => {\n\tconst contractCompileResult = await compileContract(parsedArgs, sourceFile);\n\tif (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];\n\n\tconst storageListFile = `${removeExt(sourceFile)}.storageList${extractExt(sourceFile)}`;\n\tconst storageListFilename = getInputFilename(parsedArgs, storageListFile);\n\tconst storageCompileResult = await access(storageListFilename)\n\t\t.then(() => compileExprs(parsedArgs, storageListFile, 'storage'))\n\t\t.catch(() => tryLegacyStorageNamingConvention(parsedArgs, sourceFile))\n\t\t.catch(() => {\n\t\t\tsendWarn(\n\t\t\t\t`Note: storage file associated with \"${sourceFile}\" can't be found, so \"${storageListFile}\" has been created for you. Use this file to define all initial storage values for this contract\\n`,\n\t\t\t);\n\t\t\twriteFile(storageListFilename, initContentForStorage(sourceFile), 'utf8');\n\t\t});\n\n\tconst parameterListFile = `${removeExt(sourceFile)}.parameterList${extractExt(sourceFile)}`;\n\tconst parameterListFilename = getInputFilename(parsedArgs, parameterListFile);\n\tconst parameterCompileResult = await access(parameterListFilename)\n\t\t.then(() => compileExprs(parsedArgs, parameterListFile, 'parameter'))\n\t\t.catch(() => tryLegacyParameterNamingConvention(parsedArgs, sourceFile))\n\t\t.catch(() => {\n\t\t\tsendWarn(\n\t\t\t\t`Note: parameter file associated with \"${sourceFile}\" can't be found, so \"${parameterListFile}\" has been created for you. Use this file to define all parameter values for this contract\\n`,\n\t\t\t);\n\t\t\twriteFile(parameterListFilename, initContentForParameter(sourceFile), 'utf8');\n\t\t});\n\n\tlet compileResults: TableRow[] = [contractCompileResult];\n\tif (storageCompileResult) compileResults = compileResults.concat(storageCompileResult);\n\tif (parameterCompileResult) compileResults = compileResults.concat(parameterCompileResult);\n\treturn compileResults;\n};\n\n/*\nCompiling storage/parameter file amounts to compiling multiple expressions in that file,\nresulting in multiple rows with the same file name but different artifact names.\nThis will merge these rows into one row with just one mention of the file name.\ne.g.\n┌─────────────────────────┬─────────────────────────────────────────────┐\n│ Contract │ Artifact │\n├─────────────────────────┼─────────────────────────────────────────────┤\n│ hello.storageList.mligo │ artifacts/hello.default_storage.storage1.tz │\n├─────────────────────────┼─────────────────────────────────────────────┤\n│ hello.storageList.mligo │ artifacts/hello.storage.storage2.tz │\n└─────────────────────────┴─────────────────────────────────────────────┘\n\t\t\t\t\t\t\t\tversus\n┌─────────────────────────┬─────────────────────────────────────────────┐\n│ Contract │ Artifact │\n├─────────────────────────┼─────────────────────────────────────────────┤\n│ hello.storageList.mligo │ artifacts/hello.default_storage.storage1.tz │\n│ │ artifacts/hello.storage.storage2.tz │\n└─────────────────────────┴─────────────────────────────────────────────┘\n*/\nconst mergeArtifactsOutput = (sourceFile: string) =>\n\t(tableRows: TableRow[]): TableRow[] => {\n\t\tconst artifactsOutput = tableRows.reduce(\n\t\t\t(acc: string, row: TableRow) => row.artifact === COMPILE_ERR_MSG ? acc : `${acc}${row.artifact}\\n`,\n\t\t\t'',\n\t\t);\n\t\treturn [{\n\t\t\tcontract: sourceFile,\n\t\t\tartifact: artifactsOutput,\n\t\t}];\n\t};\n\nconst compile = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = parsedArgs.sourceFile;\n\tlet p: Promise<TableRow[]>;\n\tif (isStorageListFile(sourceFile)) p = compileExprs(parsedArgs, sourceFile, 'storage');\n\telse if (isParameterListFile(sourceFile)) p = compileExprs(parsedArgs, sourceFile, 'parameter');\n\telse if (isContractFile(sourceFile)) p = compileContractWithStorageAndParameter(parsedArgs, sourceFile);\n\telse {\n\t\treturn sendAsyncErr(\n\t\t\t`${sourceFile} doesn't have a valid LIGO extension ('.ligo', '.religo', '.mligo' or '.jsligo')`,\n\t\t);\n\t}\n\treturn p.then(sendJsonRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default compile;\n","import { CmdArgEnv, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';\nimport { getLigoDockerImage, LigoOpts as Opts } from './common';\n\nconst getArbitraryLigoCmd = (parsedArgs: Opts, userArgs: string): CmdArgEnv => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst binary = 'docker';\n\tconst baseArgs = ['run', '--rm', '-v', `${projectDir}:/project`, '-w', '/project', getLigoDockerImage()];\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 = { 'DOCKER_DEFAULT_PLATFORM': 'linux/amd64' };\n\treturn [binary, args, envVars];\n};\n\nconst runArbitraryLigoCmd = (parsedArgs: Opts, cmd: string): Promise<string> =>\n\tgetArch()\n\t\t.then(() => getArbitraryLigoCmd(parsedArgs, cmd))\n\t\t.then(spawnCmd)\n\t\t.then(code =>\n\t\t\tcode !== null && code === 0\n\t\t\t\t? `Command \"${cmd}\" ran successfully by LIGO`\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 ligo = (parsedArgs: Opts): Promise<void> => {\n\tconst args = parsedArgs.command;\n\treturn runArbitraryLigoCmd(parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default ligo;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { emitExternalError, getInputFilename, getLigoDockerImage, TestOpts as Opts } from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\tconst baseCmd =\n\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;\n\tconst inputFile = getInputFilename(parsedArgs, sourceFile);\n\tconst cmd = `${baseCmd} ${inputFile}`;\n\treturn cmd;\n};\n\nconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stdout, stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t};\n\t\t})\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t};\n\t\t});\n\nconst test = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = parsedArgs.sourceFile;\n\treturn testContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default test;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
package/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ Plugin.create(i18n => ({
|
|
|
29
29
|
command: 'compile <sourceFile>',
|
|
30
30
|
aliases: ['c', 'compile-ligo'],
|
|
31
31
|
description:
|
|
32
|
-
'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated
|
|
32
|
+
'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found',
|
|
33
33
|
handler: 'proxy',
|
|
34
34
|
encoding: 'json',
|
|
35
35
|
}),
|
|
@@ -40,6 +40,13 @@ Plugin.create(i18n => ({
|
|
|
40
40
|
handler: 'proxy',
|
|
41
41
|
encoding: 'json',
|
|
42
42
|
}),
|
|
43
|
+
Task.create({
|
|
44
|
+
task: 'get-image',
|
|
45
|
+
command: 'get-image',
|
|
46
|
+
description: 'Gets the name of the image to be used',
|
|
47
|
+
handler: 'proxy',
|
|
48
|
+
hidden: true,
|
|
49
|
+
}),
|
|
43
50
|
],
|
|
44
51
|
templates: [
|
|
45
52
|
Template.create({
|
package/ligo.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CmdArgEnv, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { getLigoDockerImage, LigoOpts as Opts } from './common';
|
|
3
3
|
|
|
4
4
|
const getArbitraryLigoCmd = (parsedArgs: Opts, userArgs: string): CmdArgEnv => {
|
|
5
5
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
6
6
|
if (!projectDir) throw `No project directory provided`;
|
|
7
7
|
const binary = 'docker';
|
|
8
|
-
const baseArgs = ['run', '--rm', '-v', `${projectDir}:/project`, '-w', '/project',
|
|
8
|
+
const baseArgs = ['run', '--rm', '-v', `${projectDir}:/project`, '-w', '/project', getLigoDockerImage()];
|
|
9
9
|
const processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\-') ? arg.substring(1) : arg).filter(arg =>
|
|
10
10
|
arg
|
|
11
11
|
);
|
package/main.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { sendAsyncErr } from '@taqueria/node-sdk';
|
|
2
|
-
import { IntersectionOpts as Opts } from './common';
|
|
1
|
+
import { sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
|
|
2
|
+
import { getLigoDockerImage, IntersectionOpts as Opts } from './common';
|
|
3
3
|
import compile from './compile';
|
|
4
4
|
import ligo from './ligo';
|
|
5
5
|
import test from './test';
|
|
@@ -12,6 +12,8 @@ const main = (parsedArgs: Opts): Promise<void> => {
|
|
|
12
12
|
return compile(parsedArgs);
|
|
13
13
|
case 'test':
|
|
14
14
|
return test(parsedArgs);
|
|
15
|
+
case 'get-image':
|
|
16
|
+
return sendAsyncRes(getLigoDockerImage());
|
|
15
17
|
default:
|
|
16
18
|
return sendAsyncErr(`${parsedArgs.task} is not an understood task by the LIGO plugin`);
|
|
17
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-ligo",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.2",
|
|
4
4
|
"description": "A taqueria plugin for compiling LIGO smart contracts",
|
|
5
5
|
"targets": {
|
|
6
6
|
"default": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/ecadlabs/taqueria#readme",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@taqueria/node-sdk": "^0.24.
|
|
44
|
+
"@taqueria/node-sdk": "^0.24.2",
|
|
45
45
|
"fast-glob": "^3.2.11"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
package/test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { execCmd, getArch, sendAsyncErr,
|
|
2
|
-
import { getInputFilename,
|
|
1
|
+
import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';
|
|
2
|
+
import { emitExternalError, getInputFilename, getLigoDockerImage, TestOpts as Opts } from './common';
|
|
3
3
|
|
|
4
4
|
type TableRow = { contract: string; testResults: string };
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ const getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {
|
|
|
7
7
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
8
8
|
if (!projectDir) throw `No project directory provided`;
|
|
9
9
|
const baseCmd =
|
|
10
|
-
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${
|
|
10
|
+
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;
|
|
11
11
|
const inputFile = getInputFilename(parsedArgs, sourceFile);
|
|
12
12
|
const cmd = `${baseCmd} ${inputFile}`;
|
|
13
13
|
return cmd;
|
|
@@ -26,8 +26,7 @@ const testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =
|
|
|
26
26
|
};
|
|
27
27
|
})
|
|
28
28
|
.catch(err => {
|
|
29
|
-
|
|
30
|
-
sendErr(err.message.replace(/Command failed.+?\n/, ''));
|
|
29
|
+
emitExternalError(err, sourceFile);
|
|
31
30
|
return {
|
|
32
31
|
contract: sourceFile,
|
|
33
32
|
testResults: 'Some tests failed :(',
|