@taqueria/plugin-ligo 0.0.0-pr-946-bf7e63f2 → 0.0.0-pr-908-b2a36cb4
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/compile.ts +2 -2
- package/index.js +16 -155
- package/index.js.map +1 -1
- package/index.ts +11 -15
- package/package.json +1 -1
- package/createContract.ts +0 -40
- package/ligo_templates.ts +0 -109
package/compile.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execCmd, getArch, sendAsyncErr, sendErr, sendJsonRes } from '@taqueria/node-sdk';
|
|
2
|
-
import { RequestArgs } from '@taqueria/node-sdk/types';
|
|
2
|
+
import { LikeAPromise, PluginResponse, RequestArgs } from '@taqueria/node-sdk/types';
|
|
3
3
|
import { basename, extname, join } from 'path';
|
|
4
4
|
import glob = require('fast-glob');
|
|
5
5
|
|
|
@@ -72,7 +72,7 @@ const compileAll = (parsedArgs: Opts): Promise<{ contract: string; artifact: str
|
|
|
72
72
|
.then(promises => Promise.all(promises));
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
export const compile = (parsedArgs: Opts) => {
|
|
75
|
+
export const compile = (parsedArgs: Opts): Promise<PluginResponse> => {
|
|
76
76
|
const p = parsedArgs.sourceFile
|
|
77
77
|
? compileContract(parsedArgs)(parsedArgs.sourceFile as string)
|
|
78
78
|
.then(result => [result])
|
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var $kQNfl$taquerianodesdk = require("@taqueria/node-sdk");
|
|
2
2
|
var $kQNfl$path = require("path");
|
|
3
3
|
var $kQNfl$fastglob = require("fast-glob");
|
|
4
|
-
var $kQNfl$fspromises = require("fs/promises");
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
|
|
@@ -68,145 +67,6 @@ const $24b2f47d8f306cb3$export$ef7acd7185315e22 = (parsedArgs)=>{
|
|
|
68
67
|
var $24b2f47d8f306cb3$export$2e2bcd8739ae039 = $24b2f47d8f306cb3$export$ef7acd7185315e22;
|
|
69
68
|
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
const $9d8c61104c8e60ad$export$1336661d942c7074 = `
|
|
73
|
-
type storage = int
|
|
74
|
-
|
|
75
|
-
type parameter =
|
|
76
|
-
Increment of int
|
|
77
|
-
| Decrement of int
|
|
78
|
-
| Reset
|
|
79
|
-
|
|
80
|
-
type return = operation list * storage
|
|
81
|
-
|
|
82
|
-
// Two entrypoints
|
|
83
|
-
|
|
84
|
-
let add (store, delta : storage * int) : storage = store + delta
|
|
85
|
-
let sub (store, delta : storage * int) : storage = store - delta
|
|
86
|
-
|
|
87
|
-
(* Main access point that dispatches to the entrypoints according to
|
|
88
|
-
the smart contract parameter. *)
|
|
89
|
-
|
|
90
|
-
let main (action, store : parameter * storage) : return =
|
|
91
|
-
([] : operation list), // No operations
|
|
92
|
-
(match action with
|
|
93
|
-
Increment (n) -> add (store, n)
|
|
94
|
-
| Decrement (n) -> sub (store, n)
|
|
95
|
-
| Reset -> 0)
|
|
96
|
-
`;
|
|
97
|
-
const $9d8c61104c8e60ad$export$ec41334b92330d9b = `
|
|
98
|
-
type storage is int
|
|
99
|
-
|
|
100
|
-
type parameter is
|
|
101
|
-
Increment of int
|
|
102
|
-
| Decrement of int
|
|
103
|
-
| Reset
|
|
104
|
-
|
|
105
|
-
type return is list (operation) * storage
|
|
106
|
-
|
|
107
|
-
// Two entrypoints
|
|
108
|
-
|
|
109
|
-
function add (const store : storage; const delta : int) : storage is
|
|
110
|
-
store + delta
|
|
111
|
-
|
|
112
|
-
function sub (const store : storage; const delta : int) : storage is
|
|
113
|
-
store - delta
|
|
114
|
-
|
|
115
|
-
(* Main access point that dispatches to the entrypoints according to
|
|
116
|
-
the smart contract parameter. *)
|
|
117
|
-
|
|
118
|
-
function main (const action : parameter; const store : storage) : return is
|
|
119
|
-
((nil : list (operation)), // No operations
|
|
120
|
-
case action of [
|
|
121
|
-
Increment (n) -> add (store, n)
|
|
122
|
-
| Decrement (n) -> sub (store, n)
|
|
123
|
-
| Reset -> 0
|
|
124
|
-
])
|
|
125
|
-
`;
|
|
126
|
-
const $9d8c61104c8e60ad$export$9e59f1f7960689be = `
|
|
127
|
-
type storage = int;
|
|
128
|
-
|
|
129
|
-
type parameter =
|
|
130
|
-
Increment (int)
|
|
131
|
-
| Decrement (int)
|
|
132
|
-
| Reset;
|
|
133
|
-
|
|
134
|
-
type return = (list (operation), storage);
|
|
135
|
-
|
|
136
|
-
// Two entrypoints
|
|
137
|
-
|
|
138
|
-
let add = ((store, delta) : (storage, int)) : storage => store + delta;
|
|
139
|
-
let sub = ((store, delta) : (storage, int)) : storage => store - delta;
|
|
140
|
-
|
|
141
|
-
/* Main access point that dispatches to the entrypoints according to
|
|
142
|
-
the smart contract parameter. */
|
|
143
|
-
|
|
144
|
-
let main = ((action, store) : (parameter, storage)) : return => {
|
|
145
|
-
(([] : list (operation)), // No operations
|
|
146
|
-
(switch (action) {
|
|
147
|
-
| Increment (n) => add ((store, n))
|
|
148
|
-
| Decrement (n) => sub ((store, n))
|
|
149
|
-
| Reset => 0}))
|
|
150
|
-
};
|
|
151
|
-
`;
|
|
152
|
-
const $9d8c61104c8e60ad$export$6d35abb7f92d1079 = `
|
|
153
|
-
type storage = int;
|
|
154
|
-
|
|
155
|
-
type parameter =
|
|
156
|
-
["Increment", int]
|
|
157
|
-
| ["Decrement", int]
|
|
158
|
-
| ["Reset"];
|
|
159
|
-
|
|
160
|
-
type ret = [list<operation>, storage];
|
|
161
|
-
|
|
162
|
-
// Two entrypoints
|
|
163
|
-
|
|
164
|
-
const add = ([store, delta] : [storage, int]) : storage => store + delta;
|
|
165
|
-
const sub = ([store, delta] : [storage, int]) : storage => store - delta;
|
|
166
|
-
|
|
167
|
-
/* Main access point that dispatches to the entrypoints according to
|
|
168
|
-
the smart contract parameter. */
|
|
169
|
-
|
|
170
|
-
const main = ([action, store] : [parameter, storage]) : ret => {
|
|
171
|
-
return [list([]) as list<operation>, // No operations
|
|
172
|
-
match (action, {
|
|
173
|
-
Increment:(n: int) => add ([store, n]),
|
|
174
|
-
Decrement:(n: int) => sub ([store, n]),
|
|
175
|
-
Reset :() => 0})]
|
|
176
|
-
};
|
|
177
|
-
`;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const $40622e3a438d0515$var$registerContract = (contractName)=>{
|
|
181
|
-
console.log("Register contract", contractName);
|
|
182
|
-
// registerContract(contractName);
|
|
183
|
-
};
|
|
184
|
-
const $40622e3a438d0515$var$getLigoTemplate = (contractName)=>{
|
|
185
|
-
const matchResult = contractName.match(/\.[^.]+$/);
|
|
186
|
-
const ext = matchResult ? matchResult[0] : null;
|
|
187
|
-
switch(ext){
|
|
188
|
-
case ".mligo":
|
|
189
|
-
return 0, $9d8c61104c8e60ad$export$1336661d942c7074;
|
|
190
|
-
case ".ligo":
|
|
191
|
-
return 0, $9d8c61104c8e60ad$export$ec41334b92330d9b;
|
|
192
|
-
case ".religo":
|
|
193
|
-
return 0, $9d8c61104c8e60ad$export$9e59f1f7960689be;
|
|
194
|
-
case ".jsligo":
|
|
195
|
-
return 0, $9d8c61104c8e60ad$export$6d35abb7f92d1079;
|
|
196
|
-
default:
|
|
197
|
-
return 0, $9d8c61104c8e60ad$export$1336661d942c7074;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
const $40622e3a438d0515$var$createContract = async (arg)=>{
|
|
201
|
-
const contractName = arg.sourceFileName;
|
|
202
|
-
const contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;
|
|
203
|
-
const ligo_template = $40622e3a438d0515$var$getLigoTemplate(contractName);
|
|
204
|
-
await (0, $kQNfl$fspromises.writeFile)(`${contractsDir}/${contractName}`, ligo_template);
|
|
205
|
-
$40622e3a438d0515$var$registerContract(contractName);
|
|
206
|
-
};
|
|
207
|
-
var $40622e3a438d0515$export$2e2bcd8739ae039 = $40622e3a438d0515$var$createContract;
|
|
208
|
-
|
|
209
|
-
|
|
210
70
|
(0, $kQNfl$taquerianodesdk.Plugin).create((i18n)=>({
|
|
211
71
|
schema: "1.0",
|
|
212
72
|
version: "0.1",
|
|
@@ -241,21 +101,22 @@ var $40622e3a438d0515$export$2e2bcd8739ae039 = $40622e3a438d0515$var$createContr
|
|
|
241
101
|
encoding: "json"
|
|
242
102
|
}),
|
|
243
103
|
],
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
104
|
+
checkRuntimeDependencies: ()=>Promise.resolve({
|
|
105
|
+
status: "success",
|
|
106
|
+
report: [
|
|
107
|
+
{
|
|
108
|
+
name: "LIGO",
|
|
109
|
+
path: "ligo",
|
|
110
|
+
version: ">=0.27.0",
|
|
111
|
+
kind: "required",
|
|
112
|
+
met: true
|
|
113
|
+
},
|
|
114
|
+
]
|
|
115
|
+
}),
|
|
116
|
+
installRunTimeDependencies: ()=>Promise.resolve({
|
|
117
|
+
status: "success",
|
|
118
|
+
output: "LIGO was found in /usr/bin/ligo"
|
|
119
|
+
}),
|
|
259
120
|
proxy: (0, $24b2f47d8f306cb3$export$2e2bcd8739ae039)
|
|
260
121
|
}), process.argv);
|
|
261
122
|
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;ACAA;;;AAWA,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAC9C,CAAC,UAAkB,GAAK;QACvB,MAAM,OAAO,GAAG,CAAA,GAAA,oBAAQ,CAAA,CAAC,UAAU,EAAE,CAAA,GAAA,mBAAO,CAAA,CAAC,UAAU,CAAC,CAAC,AAAC;QAC1D,OAAO,CAAA,GAAA,gBAAI,CAAA,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;KACvD,A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AAE;oBACR,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC;wBACb,SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,YAAY;wBAClB,WAAW,EAAE,uCAAuC;qBACpD,CAAC;oBACF,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC;wBACb,SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,iCAAiC;qBAC9C,CAAC;oBACF,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC;wBACb,SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,uBAAuB;qBACpC,CAAC;iBACF;gBACD,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,MAAM;aAChB,CAAC;SACF;QACD,SAAS,EAAE;YACV,CAAA,GAAA,+BAAQ,CAAA,CAAC,MAAM,CAAC;gBACf,QAAQ,EAAE,UAAU;gBACpB,OAAO,EAAE,2BAA2B;gBACpC,WAAW,EAAE,8CAA8C;gBAC3D,WAAW,EAAE;oBACZ,CAAA,GAAA,oCAAa,CAAA,CAAC,MAAM,CAAC;wBACpB,WAAW,EAAE,gBAAgB;wBAC7B,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,2CAA2C;qBACxD,CAAC;iBACF;gBACD,OAAO,EAAE,CAAA,GAAA,wCAAc,CAAA;aACvB,CAAC;SACF;QACD,KAAK,EAAE,CAAA,GAAA,wCAAO,CAAA;KACd,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-ligo/index.ts","taqueria-plugin-ligo/compile.ts","taqueria-plugin-ligo/createContract.ts","taqueria-plugin-ligo/ligo_templates.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport compile from './compile';\nimport createContract from './createContract';\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: 'compile',\n\t\t\tcommand: 'compile [sourceFile]',\n\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\tdescription: 'Compile a smart contract written in a Ligo syntax to Michelson code',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 'e',\n\t\t\t\t\tflag: 'entrypoint',\n\t\t\t\t\tdescription: 'The entry point that will be compiled',\n\t\t\t\t}),\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\tdescription: 'The syntax used in the contract',\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tflag: 'infer',\n\t\t\t\t\tdescription: 'Enable type inference',\n\t\t\t\t}),\n\t\t\t],\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\thandler: createContract,\n\t\t}),\n\t],\n\tproxy: compile,\n}), process.argv);\n","import { execCmd, getArch, sendAsyncErr, sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk/types';\nimport { basename, extname, join } from 'path';\nimport glob = require('fast-glob');\n\ninterface Opts extends RequestArgs.t {\n\tentrypoint?: string;\n\tsyntax?: string;\n\tsourceFile?: string;\n}\n\nconst getContractArtifactFilename = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst outFile = basename(sourceFile, extname(sourceFile));\n\t\treturn join(opts.config.artifactsDir, `${outFile}.tz`);\n\t};\n\nconst getInputFilename = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\treturn join(opts.config.contractsDir, sourceFile);\n\t};\n\nconst getCompileCommand = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? opts.projectDir;\n\n\t\tif (!projectDir) throw `No project directory provided`;\n\n\t\tconst inputFile = getInputFilename(opts)(sourceFile);\n\t\tconst baseCommand =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ligolang/ligo:next compile contract ${inputFile}`;\n\t\tconst entryPoint = opts.entrypoint ? `-e ${opts.entrypoint}` : '';\n\t\tconst syntax = opts['syntax'] ? `-s ${opts['syntax']} : \"\"` : '';\n\t\tconst outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`;\n\t\tconst cmd = `${baseCommand} ${entryPoint} ${syntax} ${outFile}`;\n\t\treturn cmd;\n\t};\n\nconst compileContract = (opts: Opts) =>\n\t(sourceFile: string): Promise<{ contract: string; artifact: string }> =>\n\t\tgetArch()\n\t\t\t.then(() => getCompileCommand(opts)(sourceFile))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stderr }) => { // How should we output warnings?\n\t\t\t\tif (stderr.length > 0) sendErr(stderr);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: getContractArtifactFilename(opts)(sourceFile),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\tsendErr(' ');\n\t\t\t\tsendErr(err.message.split('\\n').slice(1).join('\\n'));\n\t\t\t\treturn Promise.resolve({\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: 'Not compiled',\n\t\t\t\t});\n\t\t\t});\n\nconst compileAll = (parsedArgs: Opts): Promise<{ contract: string; artifact: string }[]> => {\n\t// TODO: Fetch list of files from SDK\n\treturn glob(\n\t\t['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n\t\t{ cwd: parsedArgs.config.contractsDir, absolute: false },\n\t)\n\t\t.then(entries => entries.map(compileContract(parsedArgs)))\n\t\t.then(processes =>\n\t\t\tprocesses.length > 0\n\t\t\t\t? processes\n\t\t\t\t: [{ contract: 'None found', artifact: 'N/A' }]\n\t\t)\n\t\t.then(promises => Promise.all(promises));\n};\n\nexport const compile = (parsedArgs: Opts) => {\n\tconst p = parsedArgs.sourceFile\n\t\t? compileContract(parsedArgs)(parsedArgs.sourceFile as string)\n\t\t\t.then(result => [result])\n\t\t: compileAll(parsedArgs)\n\t\t\t.then(results => {\n\t\t\t\tif (results.length === 0) sendErr('No contracts found to compile.');\n\t\t\t\treturn results;\n\t\t\t});\n\n\treturn p\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n};\n\nexport default compile;\n","import * as RequestArgs from '@taqueria/protocol/RequestArgs';\n// import { experimental } from '@taqueria/node-sdk';\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}\n\nconst registerContract = (contractName: string) => {\n\tconsole.log('Register contract', contractName);\n\t// registerContract(contractName);\n};\n\nconst getLigoTemplate = (contractName: string): string => {\n\tconst matchResult = contractName.match(/\\.[^.]+$/);\n\tconst ext = matchResult ? matchResult[0] : null;\n\tswitch (ext) {\n\t\tcase '.mligo':\n\t\t\treturn mligo_template;\n\t\tcase '.ligo':\n\t\t\treturn pascaligo_template;\n\t\tcase '.religo':\n\t\t\treturn religo_template;\n\t\tcase '.jsligo':\n\t\t\treturn jsligo_template;\n\t\tdefault:\n\t\t\treturn mligo_template;\n\t}\n};\n\nconst createContract = async (arg: Opts) => {\n\tconst contractName = arg.sourceFileName as string;\n\tconst contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;\n\tconst ligo_template = getLigoTemplate(contractName);\n\tawait writeFile(`${contractsDir}/${contractName}`, ligo_template);\n\tregisterContract(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"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":";;;;AAAA;ACAA;;;AAWA,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAC9C,CAAC,UAAkB,GAAK;QACvB,MAAM,OAAO,GAAG,CAAA,GAAA,oBAAQ,CAAA,CAAC,UAAU,EAAE,CAAA,GAAA,mBAAO,CAAA,CAAC,UAAU,CAAC,CAAC,AAAC;QAC1D,OAAO,CAAA,GAAA,gBAAI,CAAA,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;KACvD,AAAC;AAEH,MAAM,sCAAgB,GAAG,CAAC,IAAU,GACnC,CAAC,UAAkB,GAAK;QACvB,OAAO,CAAA,GAAA,gBAAI,CAAA,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;KAClD,AAAC;AAEH,MAAM,uCAAiB,GAAG,CAAC,IAAU,GACpC,CAAC,UAAkB,GAAK;QACvB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,AAAC;QAE9D,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,6BAA6B,CAAC,CAAC;QAEvD,MAAM,SAAS,GAAG,sCAAgB,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,AAAC;QACrD,MAAM,WAAW,GAChB,CAAC,yDAAyD,EAAE,UAAU,CAAC,iFAAiF,EAAE,SAAS,CAAC,CAAC,AAAC;QACvK,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,CAA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AC;gBACf,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,iCAAiC;aACzC,CAAC;QACH,KAAK,EAAE,CAAA,GAAA,wCAAO,CAAA;KACd,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-ligo/index.ts","taqueria-plugin-ligo/compile.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport compile from './compile';\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: 'compile',\n\t\t\tcommand: 'compile [sourceFile]',\n\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\tdescription: 'Compile a smart contract written in a Ligo syntax to Michelson code',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 'e',\n\t\t\t\t\tflag: 'entrypoint',\n\t\t\t\t\tdescription: 'The entry point that will be compiled',\n\t\t\t\t}),\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\tdescription: 'The syntax used in the contract',\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tflag: 'infer',\n\t\t\t\t\tdescription: 'Enable type inference',\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tcheckRuntimeDependencies: () =>\n\t\tPromise.resolve({\n\t\t\tstatus: 'success',\n\t\t\treport: [\n\t\t\t\t{ name: 'LIGO', path: 'ligo', version: '>=0.27.0', kind: 'required', met: true },\n\t\t\t],\n\t\t}),\n\tinstallRunTimeDependencies: () =>\n\t\tPromise.resolve({\n\t\t\tstatus: 'success',\n\t\t\toutput: 'LIGO was found in /usr/bin/ligo', // TODO this should use i18n\n\t\t}),\n\tproxy: compile,\n}), process.argv);\n","import { execCmd, getArch, sendAsyncErr, sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport { LikeAPromise, PluginResponse, RequestArgs } from '@taqueria/node-sdk/types';\nimport { basename, extname, join } from 'path';\nimport glob = require('fast-glob');\n\ninterface Opts extends RequestArgs.t {\n\tentrypoint?: string;\n\tsyntax?: string;\n\tsourceFile?: string;\n}\n\nconst getContractArtifactFilename = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst outFile = basename(sourceFile, extname(sourceFile));\n\t\treturn join(opts.config.artifactsDir, `${outFile}.tz`);\n\t};\n\nconst getInputFilename = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\treturn join(opts.config.contractsDir, sourceFile);\n\t};\n\nconst getCompileCommand = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? opts.projectDir;\n\n\t\tif (!projectDir) throw `No project directory provided`;\n\n\t\tconst inputFile = getInputFilename(opts)(sourceFile);\n\t\tconst baseCommand =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ligolang/ligo:next compile contract ${inputFile}`;\n\t\tconst entryPoint = opts.entrypoint ? `-e ${opts.entrypoint}` : '';\n\t\tconst syntax = opts['syntax'] ? `-s ${opts['syntax']} : \"\"` : '';\n\t\tconst outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`;\n\t\tconst cmd = `${baseCommand} ${entryPoint} ${syntax} ${outFile}`;\n\t\treturn cmd;\n\t};\n\nconst compileContract = (opts: Opts) =>\n\t(sourceFile: string): Promise<{ contract: string; artifact: string }> =>\n\t\tgetArch()\n\t\t\t.then(() => getCompileCommand(opts)(sourceFile))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stderr }) => { // How should we output warnings?\n\t\t\t\tif (stderr.length > 0) sendErr(stderr);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: getContractArtifactFilename(opts)(sourceFile),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\tsendErr(' ');\n\t\t\t\tsendErr(err.message.split('\\n').slice(1).join('\\n'));\n\t\t\t\treturn Promise.resolve({\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: 'Not compiled',\n\t\t\t\t});\n\t\t\t});\n\nconst compileAll = (parsedArgs: Opts): Promise<{ contract: string; artifact: string }[]> => {\n\t// TODO: Fetch list of files from SDK\n\treturn glob(\n\t\t['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n\t\t{ cwd: parsedArgs.config.contractsDir, absolute: false },\n\t)\n\t\t.then(entries => entries.map(compileContract(parsedArgs)))\n\t\t.then(processes =>\n\t\t\tprocesses.length > 0\n\t\t\t\t? processes\n\t\t\t\t: [{ contract: 'None found', artifact: 'N/A' }]\n\t\t)\n\t\t.then(promises => Promise.all(promises));\n};\n\nexport const compile = (parsedArgs: Opts): Promise<PluginResponse> => {\n\tconst p = parsedArgs.sourceFile\n\t\t? compileContract(parsedArgs)(parsedArgs.sourceFile as string)\n\t\t\t.then(result => [result])\n\t\t: compileAll(parsedArgs)\n\t\t\t.then(results => {\n\t\t\t\tif (results.length === 0) sendErr('No contracts found to compile.');\n\t\t\t\treturn results;\n\t\t\t});\n\n\treturn p\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n};\n\nexport default compile;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Option, Plugin,
|
|
1
|
+
import { Option, Plugin, Task } from '@taqueria/node-sdk';
|
|
2
2
|
import compile from './compile';
|
|
3
|
-
import createContract from './createContract';
|
|
4
3
|
|
|
5
4
|
Plugin.create(i18n => ({
|
|
6
5
|
schema: '1.0',
|
|
@@ -33,20 +32,17 @@ Plugin.create(i18n => ({
|
|
|
33
32
|
encoding: 'json',
|
|
34
33
|
}),
|
|
35
34
|
],
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
positionals: [
|
|
42
|
-
PositionalArg.create({
|
|
43
|
-
placeholder: 'sourceFileName',
|
|
44
|
-
type: 'string',
|
|
45
|
-
description: 'The name of the LIGO contract to generate',
|
|
46
|
-
}),
|
|
35
|
+
checkRuntimeDependencies: () =>
|
|
36
|
+
Promise.resolve({
|
|
37
|
+
status: 'success',
|
|
38
|
+
report: [
|
|
39
|
+
{ name: 'LIGO', path: 'ligo', version: '>=0.27.0', kind: 'required', met: true },
|
|
47
40
|
],
|
|
48
|
-
handler: createContract,
|
|
49
41
|
}),
|
|
50
|
-
|
|
42
|
+
installRunTimeDependencies: () =>
|
|
43
|
+
Promise.resolve({
|
|
44
|
+
status: 'success',
|
|
45
|
+
output: 'LIGO was found in /usr/bin/ligo', // TODO this should use i18n
|
|
46
|
+
}),
|
|
51
47
|
proxy: compile,
|
|
52
48
|
}), process.argv);
|
package/package.json
CHANGED
package/createContract.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as RequestArgs from '@taqueria/protocol/RequestArgs';
|
|
2
|
-
// import { experimental } from '@taqueria/node-sdk';
|
|
3
|
-
import { writeFile } from 'fs/promises';
|
|
4
|
-
import { jsligo_template, mligo_template, pascaligo_template, religo_template } from './ligo_templates';
|
|
5
|
-
|
|
6
|
-
interface Opts extends RequestArgs.t {
|
|
7
|
-
sourceFileName?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const registerContract = (contractName: string) => {
|
|
11
|
-
console.log('Register contract', contractName);
|
|
12
|
-
// registerContract(contractName);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const getLigoTemplate = (contractName: string): string => {
|
|
16
|
-
const matchResult = contractName.match(/\.[^.]+$/);
|
|
17
|
-
const ext = matchResult ? matchResult[0] : null;
|
|
18
|
-
switch (ext) {
|
|
19
|
-
case '.mligo':
|
|
20
|
-
return mligo_template;
|
|
21
|
-
case '.ligo':
|
|
22
|
-
return pascaligo_template;
|
|
23
|
-
case '.religo':
|
|
24
|
-
return religo_template;
|
|
25
|
-
case '.jsligo':
|
|
26
|
-
return jsligo_template;
|
|
27
|
-
default:
|
|
28
|
-
return mligo_template;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const createContract = async (arg: Opts) => {
|
|
33
|
-
const contractName = arg.sourceFileName as string;
|
|
34
|
-
const contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;
|
|
35
|
-
const ligo_template = getLigoTemplate(contractName);
|
|
36
|
-
await writeFile(`${contractsDir}/${contractName}`, ligo_template);
|
|
37
|
-
registerContract(contractName);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default createContract;
|
package/ligo_templates.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
export const mligo_template = `
|
|
2
|
-
type storage = int
|
|
3
|
-
|
|
4
|
-
type parameter =
|
|
5
|
-
Increment of int
|
|
6
|
-
| Decrement of int
|
|
7
|
-
| Reset
|
|
8
|
-
|
|
9
|
-
type return = operation list * storage
|
|
10
|
-
|
|
11
|
-
// Two entrypoints
|
|
12
|
-
|
|
13
|
-
let add (store, delta : storage * int) : storage = store + delta
|
|
14
|
-
let sub (store, delta : storage * int) : storage = store - delta
|
|
15
|
-
|
|
16
|
-
(* Main access point that dispatches to the entrypoints according to
|
|
17
|
-
the smart contract parameter. *)
|
|
18
|
-
|
|
19
|
-
let main (action, store : parameter * storage) : return =
|
|
20
|
-
([] : operation list), // No operations
|
|
21
|
-
(match action with
|
|
22
|
-
Increment (n) -> add (store, n)
|
|
23
|
-
| Decrement (n) -> sub (store, n)
|
|
24
|
-
| Reset -> 0)
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
export const pascaligo_template = `
|
|
28
|
-
type storage is int
|
|
29
|
-
|
|
30
|
-
type parameter is
|
|
31
|
-
Increment of int
|
|
32
|
-
| Decrement of int
|
|
33
|
-
| Reset
|
|
34
|
-
|
|
35
|
-
type return is list (operation) * storage
|
|
36
|
-
|
|
37
|
-
// Two entrypoints
|
|
38
|
-
|
|
39
|
-
function add (const store : storage; const delta : int) : storage is
|
|
40
|
-
store + delta
|
|
41
|
-
|
|
42
|
-
function sub (const store : storage; const delta : int) : storage is
|
|
43
|
-
store - delta
|
|
44
|
-
|
|
45
|
-
(* Main access point that dispatches to the entrypoints according to
|
|
46
|
-
the smart contract parameter. *)
|
|
47
|
-
|
|
48
|
-
function main (const action : parameter; const store : storage) : return is
|
|
49
|
-
((nil : list (operation)), // No operations
|
|
50
|
-
case action of [
|
|
51
|
-
Increment (n) -> add (store, n)
|
|
52
|
-
| Decrement (n) -> sub (store, n)
|
|
53
|
-
| Reset -> 0
|
|
54
|
-
])
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
export const religo_template = `
|
|
58
|
-
type storage = int;
|
|
59
|
-
|
|
60
|
-
type parameter =
|
|
61
|
-
Increment (int)
|
|
62
|
-
| Decrement (int)
|
|
63
|
-
| Reset;
|
|
64
|
-
|
|
65
|
-
type return = (list (operation), storage);
|
|
66
|
-
|
|
67
|
-
// Two entrypoints
|
|
68
|
-
|
|
69
|
-
let add = ((store, delta) : (storage, int)) : storage => store + delta;
|
|
70
|
-
let sub = ((store, delta) : (storage, int)) : storage => store - delta;
|
|
71
|
-
|
|
72
|
-
/* Main access point that dispatches to the entrypoints according to
|
|
73
|
-
the smart contract parameter. */
|
|
74
|
-
|
|
75
|
-
let main = ((action, store) : (parameter, storage)) : return => {
|
|
76
|
-
(([] : list (operation)), // No operations
|
|
77
|
-
(switch (action) {
|
|
78
|
-
| Increment (n) => add ((store, n))
|
|
79
|
-
| Decrement (n) => sub ((store, n))
|
|
80
|
-
| Reset => 0}))
|
|
81
|
-
};
|
|
82
|
-
`;
|
|
83
|
-
|
|
84
|
-
export const jsligo_template = `
|
|
85
|
-
type storage = int;
|
|
86
|
-
|
|
87
|
-
type parameter =
|
|
88
|
-
["Increment", int]
|
|
89
|
-
| ["Decrement", int]
|
|
90
|
-
| ["Reset"];
|
|
91
|
-
|
|
92
|
-
type ret = [list<operation>, storage];
|
|
93
|
-
|
|
94
|
-
// Two entrypoints
|
|
95
|
-
|
|
96
|
-
const add = ([store, delta] : [storage, int]) : storage => store + delta;
|
|
97
|
-
const sub = ([store, delta] : [storage, int]) : storage => store - delta;
|
|
98
|
-
|
|
99
|
-
/* Main access point that dispatches to the entrypoints according to
|
|
100
|
-
the smart contract parameter. */
|
|
101
|
-
|
|
102
|
-
const main = ([action, store] : [parameter, storage]) : ret => {
|
|
103
|
-
return [list([]) as list<operation>, // No operations
|
|
104
|
-
match (action, {
|
|
105
|
-
Increment:(n: int) => add ([store, n]),
|
|
106
|
-
Decrement:(n: int) => sub ([store, n]),
|
|
107
|
-
Reset :() => 0})]
|
|
108
|
-
};
|
|
109
|
-
`;
|