@clarigen/cli 2.1.1 → 2.1.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/dist/index.cjs +190 -158
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +444 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +181 -160
- package/dist/index.js.map +1 -1
- package/dist/run-cli.cjs +239 -202
- package/dist/run-cli.cjs.map +1 -1
- package/dist/run-cli.d.cts +1 -0
- package/dist/run-cli.js +230 -203
- package/dist/run-cli.js.map +1 -1
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
1
|
// src/docs/markdown.ts
|
|
34
2
|
import { getContractName as getContractName2, getTypeString } from "@clarigen/core";
|
|
35
3
|
|
|
@@ -37,12 +5,14 @@ import { getContractName as getContractName2, getTypeString } from "@clarigen/co
|
|
|
37
5
|
import { pino } from "pino";
|
|
38
6
|
import pinoPretty from "pino-pretty";
|
|
39
7
|
var colorizedClarigen = `\x1B[33m[Clarigen]\x1B[0m`;
|
|
40
|
-
var logger = pino(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
8
|
+
var logger = pino(
|
|
9
|
+
pinoPretty({
|
|
10
|
+
colorize: true,
|
|
11
|
+
ignore: "pid,hostname,time",
|
|
12
|
+
messageFormat: `${colorizedClarigen} {msg}`,
|
|
13
|
+
minimumLevel: "debug"
|
|
14
|
+
})
|
|
15
|
+
);
|
|
46
16
|
logger.level = "info";
|
|
47
17
|
var log = logger;
|
|
48
18
|
|
|
@@ -138,8 +108,7 @@ function findItemNameFromLine(line) {
|
|
|
138
108
|
}
|
|
139
109
|
for (const type of VAR_TYPES) {
|
|
140
110
|
const prefix = `(define-${type} `;
|
|
141
|
-
if (!line.startsWith(prefix))
|
|
142
|
-
continue;
|
|
111
|
+
if (!line.startsWith(prefix)) continue;
|
|
143
112
|
const startString = line.slice(prefix.length);
|
|
144
113
|
const match = clarityNameMatcher(startString);
|
|
145
114
|
if (!match) {
|
|
@@ -155,11 +124,9 @@ function findAbiItemByName(abi, name) {
|
|
|
155
124
|
const fn = abi.functions.find((fn2) => {
|
|
156
125
|
return fn2.name === name;
|
|
157
126
|
});
|
|
158
|
-
if (fn)
|
|
159
|
-
return fn;
|
|
127
|
+
if (fn) return fn;
|
|
160
128
|
const map = abi.maps.find((m) => m.name === name);
|
|
161
|
-
if (map)
|
|
162
|
-
return map;
|
|
129
|
+
if (map) return map;
|
|
163
130
|
const v = abi.variables.find((v2) => v2.name === name);
|
|
164
131
|
return v;
|
|
165
132
|
}
|
|
@@ -170,8 +137,7 @@ function getFnName(line) {
|
|
|
170
137
|
const fnType = FN_TYPES.find((type) => {
|
|
171
138
|
return line.startsWith(`(define-${type}`);
|
|
172
139
|
});
|
|
173
|
-
if (typeof fnType === "undefined")
|
|
174
|
-
return;
|
|
140
|
+
if (typeof fnType === "undefined") return;
|
|
175
141
|
const prefix = `(define-${fnType} (`;
|
|
176
142
|
const startString = line.slice(prefix.length);
|
|
177
143
|
const match = clarityNameMatcher(startString);
|
|
@@ -185,10 +151,8 @@ function getFnName(line) {
|
|
|
185
151
|
function traceParens(line, count) {
|
|
186
152
|
let newCount = count;
|
|
187
153
|
line.split("").forEach((char) => {
|
|
188
|
-
if (char === "(")
|
|
189
|
-
|
|
190
|
-
if (char === ")")
|
|
191
|
-
newCount--;
|
|
154
|
+
if (char === "(") newCount++;
|
|
155
|
+
if (char === ")") newCount--;
|
|
192
156
|
});
|
|
193
157
|
return newCount;
|
|
194
158
|
}
|
|
@@ -209,8 +173,7 @@ function parseComments(comments, abi) {
|
|
|
209
173
|
}
|
|
210
174
|
return;
|
|
211
175
|
}
|
|
212
|
-
if (!("args" in abi))
|
|
213
|
-
return;
|
|
176
|
+
if (!("args" in abi)) return;
|
|
214
177
|
const [_full, name, _separator, rest] = paramMatches;
|
|
215
178
|
const arg = abi.args.find((arg2) => arg2.name === name);
|
|
216
179
|
if (!arg) {
|
|
@@ -238,8 +201,7 @@ function parseComments(comments, abi) {
|
|
|
238
201
|
async function afterDocs(config) {
|
|
239
202
|
var _a;
|
|
240
203
|
const command = (_a = config.docs) == null ? void 0 : _a.after;
|
|
241
|
-
if (!command)
|
|
242
|
-
return;
|
|
204
|
+
if (!command) return;
|
|
243
205
|
logger.debug(`Running after docs command: ${command}`);
|
|
244
206
|
const parts = command.split(" ");
|
|
245
207
|
const [cmd, ...args] = parts;
|
|
@@ -267,8 +229,7 @@ import { getContractName, toCamelCase } from "@clarigen/core";
|
|
|
267
229
|
import { stat, mkdir, writeFile as fsWriteFile } from "fs/promises";
|
|
268
230
|
import { dirname, relative } from "path";
|
|
269
231
|
function encodeVariableName(name) {
|
|
270
|
-
if (/^[A-Z\-_]*$/.test(name))
|
|
271
|
-
return name.replaceAll("-", "_");
|
|
232
|
+
if (/^[A-Z\-_]*$/.test(name)) return name.replaceAll("-", "_");
|
|
272
233
|
return toCamelCase(name);
|
|
273
234
|
}
|
|
274
235
|
async function fileExists(filename) {
|
|
@@ -363,7 +324,9 @@ ${fn.source.join("\n")}
|
|
|
363
324
|
\`\`\`
|
|
364
325
|
</details>
|
|
365
326
|
`;
|
|
366
|
-
const sig = `(define-${fn.abi.access.replace("_", "-")} (${fn.abi.name} (${paramSigs.join(
|
|
327
|
+
const sig = `(define-${fn.abi.access.replace("_", "-")} (${fn.abi.name} (${paramSigs.join(
|
|
328
|
+
" "
|
|
329
|
+
)}) ${returnType})`;
|
|
367
330
|
return `### ${fn.abi.name}
|
|
368
331
|
|
|
369
332
|
${link}
|
|
@@ -377,8 +340,7 @@ ${source}
|
|
|
377
340
|
${params}`;
|
|
378
341
|
}
|
|
379
342
|
function mdParams(fn) {
|
|
380
|
-
if (fn.abi.args.length === 0)
|
|
381
|
-
return "";
|
|
343
|
+
if (fn.abi.args.length === 0) return "";
|
|
382
344
|
const hasDescription = Object.values(fn.comments.params).some((p) => p.comments.length > 0);
|
|
383
345
|
const params = Object.values(fn.comments.params).map((p) => markdownParam(p, hasDescription));
|
|
384
346
|
return `**Parameters:**
|
|
@@ -390,8 +352,7 @@ ${params.join("\n")}`;
|
|
|
390
352
|
function markdownParam(param, withDescription) {
|
|
391
353
|
const typeString = getTypeString(param.abi.type);
|
|
392
354
|
const base = `| ${param.abi.name} | ${typeString} |`;
|
|
393
|
-
if (!withDescription)
|
|
394
|
-
return base;
|
|
355
|
+
if (!withDescription) return base;
|
|
395
356
|
return `${base} ${param.comments.join(" ")} |`;
|
|
396
357
|
}
|
|
397
358
|
function markdownMap(map, contractFile) {
|
|
@@ -469,8 +430,7 @@ function generateReadme(session, excluded) {
|
|
|
469
430
|
const contractLines = [];
|
|
470
431
|
sortContracts(session.contracts).forEach((contract) => {
|
|
471
432
|
const name = getContractName2(contract.contract_id, false);
|
|
472
|
-
if (excluded[name])
|
|
473
|
-
return;
|
|
433
|
+
if (excluded[name]) return;
|
|
474
434
|
const fileName = `${name}.md`;
|
|
475
435
|
const line = `- [\`${name}\`](${fileName})`;
|
|
476
436
|
contractLines.push(line);
|
|
@@ -556,26 +516,25 @@ var Config = class {
|
|
|
556
516
|
var _a, _b;
|
|
557
517
|
const singlePath = (_a = this.configFile[type]) == null ? void 0 : _a.output;
|
|
558
518
|
const multiPath = ((_b = this.configFile[type]) == null ? void 0 : _b.outputs) || [];
|
|
559
|
-
if (singlePath !== void 0)
|
|
560
|
-
return [singlePath];
|
|
519
|
+
if (singlePath !== void 0) return [singlePath];
|
|
561
520
|
return multiPath;
|
|
562
521
|
}
|
|
563
522
|
outputResolve(type, filePath) {
|
|
564
523
|
const outputs = this.getOutputs(type);
|
|
565
|
-
if (!this.supports(type))
|
|
566
|
-
return null;
|
|
524
|
+
if (!this.supports(type)) return null;
|
|
567
525
|
return outputs.map((path) => {
|
|
568
526
|
return resolve2(this.cwd, path, filePath || "");
|
|
569
527
|
});
|
|
570
528
|
}
|
|
571
529
|
async writeOutput(type, contents, filePath) {
|
|
572
530
|
const paths = this.outputResolve(type, filePath);
|
|
573
|
-
if (paths === null)
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
531
|
+
if (paths === null) return null;
|
|
532
|
+
await Promise.all(
|
|
533
|
+
paths.map(async (path) => {
|
|
534
|
+
await writeFile(path, contents);
|
|
535
|
+
log.debug(`Generated ${type} file at ${relative2(this.cwd, path)}`);
|
|
536
|
+
})
|
|
537
|
+
);
|
|
579
538
|
return paths;
|
|
580
539
|
}
|
|
581
540
|
supports(type) {
|
|
@@ -602,13 +561,12 @@ function configFilePath(cwd) {
|
|
|
602
561
|
return resolve2(cwd ?? process.cwd(), CONFIG_FILE);
|
|
603
562
|
}
|
|
604
563
|
async function saveConfig(config) {
|
|
605
|
-
const configToml = stringify(
|
|
564
|
+
const configToml = stringify({ ...config });
|
|
606
565
|
await writeFile(configFilePath(), configToml);
|
|
607
566
|
}
|
|
608
567
|
var sessionConfig;
|
|
609
568
|
async function getConfig(cwd) {
|
|
610
|
-
if (typeof sessionConfig !== "undefined")
|
|
611
|
-
return sessionConfig;
|
|
569
|
+
if (typeof sessionConfig !== "undefined") return sessionConfig;
|
|
612
570
|
const path = configFilePath(cwd);
|
|
613
571
|
if (await fileExists(path)) {
|
|
614
572
|
const toml = await readFile2(path, "utf-8");
|
|
@@ -646,42 +604,47 @@ async function generateDocs({
|
|
|
646
604
|
if (docsPathExt) {
|
|
647
605
|
log.warn(`Docs output path ('${docsBase}') looks like a file - it needs to be a directory.`);
|
|
648
606
|
}
|
|
649
|
-
const excluded = Object.fromEntries(
|
|
650
|
-
|
|
651
|
-
|
|
607
|
+
const excluded = Object.fromEntries(
|
|
608
|
+
(docs.exclude || []).map((e) => {
|
|
609
|
+
return [e, true];
|
|
610
|
+
})
|
|
611
|
+
);
|
|
652
612
|
log.debug(`Generating docs at path \`${docsBase}\``);
|
|
653
613
|
const docsBaseFolder = config.outputResolve("docs" /* Docs */, "./")[0];
|
|
654
|
-
const paths = await Promise.all(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
return null;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
614
|
+
const paths = await Promise.all(
|
|
615
|
+
session.contracts.map(async (contract) => {
|
|
616
|
+
var _a, _b;
|
|
617
|
+
const name = getContractName3(contract.contract_id, false);
|
|
618
|
+
if (excluded[name]) return null;
|
|
619
|
+
const docFile = `${name}.md`;
|
|
620
|
+
const contractPathDef = (_b = (_a = config.clarinet.contracts) == null ? void 0 : _a[name]) == null ? void 0 : _b.path;
|
|
621
|
+
let contractFile;
|
|
622
|
+
if (contractPathDef) {
|
|
623
|
+
const contractPathFull = config.joinFromClarinet(contractPathDef);
|
|
624
|
+
contractFile = relative3(docsBaseFolder, contractPathFull);
|
|
625
|
+
} else {
|
|
626
|
+
log.debug(`Couldn't find contract file from Clarinet.toml for contract ${name}`);
|
|
627
|
+
}
|
|
628
|
+
const md = generateMarkdown({ contract, contractFile });
|
|
629
|
+
const path = await config.writeOutput("docs" /* Docs */, md, docFile);
|
|
630
|
+
return path[0];
|
|
631
|
+
})
|
|
632
|
+
);
|
|
672
633
|
const readme = generateReadme(session, excluded);
|
|
673
634
|
paths.push((await config.writeOutput("docs" /* Docs */, readme, "README.md"))[0]);
|
|
674
635
|
await afterDocs(config);
|
|
675
636
|
}
|
|
676
637
|
function warnNoDocs() {
|
|
677
|
-
log.warn(
|
|
638
|
+
log.warn(
|
|
639
|
+
`
|
|
678
640
|
Clarigen config file doesn't include an output directory for docs.
|
|
679
641
|
|
|
680
642
|
To generate docs, specify 'docs.output' in your config file:
|
|
681
643
|
|
|
682
644
|
[docs]
|
|
683
645
|
output = "docs/"
|
|
684
|
-
`.trimEnd()
|
|
646
|
+
`.trimEnd()
|
|
647
|
+
);
|
|
685
648
|
}
|
|
686
649
|
|
|
687
650
|
// src/files/variables.ts
|
|
@@ -706,12 +669,10 @@ import { toCamelCase as toCamelCase2 } from "@clarigen/core";
|
|
|
706
669
|
var jsTypeFromAbiType = (val, isArgument = false) => {
|
|
707
670
|
if (isClarityAbiPrimitive(val)) {
|
|
708
671
|
if (val === "uint128") {
|
|
709
|
-
if (isArgument)
|
|
710
|
-
return "number | bigint";
|
|
672
|
+
if (isArgument) return "number | bigint";
|
|
711
673
|
return "bigint";
|
|
712
674
|
} else if (val === "int128") {
|
|
713
|
-
if (isArgument)
|
|
714
|
-
return "number | bigint";
|
|
675
|
+
if (isArgument) return "number | bigint";
|
|
715
676
|
return "bigint";
|
|
716
677
|
} else if (val === "bool") {
|
|
717
678
|
return "boolean";
|
|
@@ -779,7 +740,50 @@ function _hash(...words) {
|
|
|
779
740
|
}
|
|
780
741
|
return h;
|
|
781
742
|
}
|
|
782
|
-
var RESERVED = _hash(
|
|
743
|
+
var RESERVED = _hash(
|
|
744
|
+
// Keywords, ES6 11.6.2.1, http://www.ecma-international.org/ecma-262/6.0/index.html#sec-keywords
|
|
745
|
+
"break",
|
|
746
|
+
"do",
|
|
747
|
+
"in",
|
|
748
|
+
"typeof",
|
|
749
|
+
"case",
|
|
750
|
+
"else",
|
|
751
|
+
"instanceof",
|
|
752
|
+
"var",
|
|
753
|
+
"catch",
|
|
754
|
+
"export",
|
|
755
|
+
"new",
|
|
756
|
+
"void",
|
|
757
|
+
"class",
|
|
758
|
+
"extends",
|
|
759
|
+
"return",
|
|
760
|
+
"while",
|
|
761
|
+
"const",
|
|
762
|
+
"finally",
|
|
763
|
+
"super",
|
|
764
|
+
"with",
|
|
765
|
+
"continue",
|
|
766
|
+
"for",
|
|
767
|
+
"switch",
|
|
768
|
+
"yield",
|
|
769
|
+
"debugger",
|
|
770
|
+
"function",
|
|
771
|
+
"this",
|
|
772
|
+
"default",
|
|
773
|
+
"if",
|
|
774
|
+
"throw",
|
|
775
|
+
"delete",
|
|
776
|
+
"import",
|
|
777
|
+
"try",
|
|
778
|
+
// Future Reserved Words, ES6 11.6.2.2
|
|
779
|
+
// http://www.ecma-international.org/ecma-262/6.0/index.html#sec-future-reserved-words
|
|
780
|
+
"enum",
|
|
781
|
+
"await",
|
|
782
|
+
// NullLiteral & BooleanLiteral
|
|
783
|
+
"null",
|
|
784
|
+
"true",
|
|
785
|
+
"false"
|
|
786
|
+
);
|
|
783
787
|
|
|
784
788
|
// src/files/base.ts
|
|
785
789
|
import { toCamelCase as toCamelCase3 } from "@clarigen/core";
|
|
@@ -787,10 +791,12 @@ import { toCamelCase as toCamelCase3 } from "@clarigen/core";
|
|
|
787
791
|
// src/files/accounts.ts
|
|
788
792
|
function generateAccountsCode(accounts) {
|
|
789
793
|
const sortedAccounts = sortAccounts(accounts);
|
|
790
|
-
const namedAccounts = Object.fromEntries(
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
+
const namedAccounts = Object.fromEntries(
|
|
795
|
+
sortedAccounts.map((a) => {
|
|
796
|
+
const { name, ...rest } = a;
|
|
797
|
+
return [name, rest];
|
|
798
|
+
})
|
|
799
|
+
);
|
|
794
800
|
return JSON.stringify(namedAccounts);
|
|
795
801
|
}
|
|
796
802
|
function sortAccounts(accounts) {
|
|
@@ -806,10 +812,12 @@ function sortAccounts(accounts) {
|
|
|
806
812
|
// src/files/identifiers.ts
|
|
807
813
|
import { getContractName as getContractName4 } from "@clarigen/core";
|
|
808
814
|
function generateIdentifiers(session) {
|
|
809
|
-
const identifiers = Object.fromEntries(
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
815
|
+
const identifiers = Object.fromEntries(
|
|
816
|
+
sortContracts(session.contracts).map((c) => {
|
|
817
|
+
const contractName = getContractName4(c.contract_id);
|
|
818
|
+
return [contractName, c.contract_id];
|
|
819
|
+
})
|
|
820
|
+
);
|
|
813
821
|
return identifiers;
|
|
814
822
|
}
|
|
815
823
|
function generateIdentifiersCode(session) {
|
|
@@ -822,7 +830,7 @@ import { inspect } from "util";
|
|
|
822
830
|
function generateContractMeta(contract, constants) {
|
|
823
831
|
const abi = contract.contract_interface;
|
|
824
832
|
const functionLines = [];
|
|
825
|
-
const
|
|
833
|
+
const { functions, maps, variables, non_fungible_tokens, ...rest } = abi;
|
|
826
834
|
functions.forEach((func) => {
|
|
827
835
|
let functionLine = `${toCamelCase3(func.name)}: `;
|
|
828
836
|
const funcDef = JSON.stringify(func);
|
|
@@ -857,7 +865,8 @@ function generateContractMeta(contract, constants) {
|
|
|
857
865
|
}
|
|
858
866
|
var TYPE_IMPORTS = `import type { TypedAbiArg, TypedAbiFunction, TypedAbiMap, TypedAbiVariable, Response } from '@clarigen/core';`;
|
|
859
867
|
function generateBaseFile(session) {
|
|
860
|
-
const combined = session.contracts.map((c, i) =>
|
|
868
|
+
const combined = session.contracts.map((c, i) => ({
|
|
869
|
+
...c,
|
|
861
870
|
constants: session.variables[i]
|
|
862
871
|
}));
|
|
863
872
|
const contractDefs = sortContracts(combined).map((contract) => {
|
|
@@ -900,14 +909,20 @@ Uint8Array.prototype[inspect.custom] = function(depth, options) {
|
|
|
900
909
|
};
|
|
901
910
|
function serialize(obj) {
|
|
902
911
|
return inspect(obj, {
|
|
912
|
+
// showHidden: false,
|
|
913
|
+
// depth: 100,
|
|
914
|
+
// colors: false,
|
|
903
915
|
showHidden: false,
|
|
916
|
+
// iterableLimit: 100000,
|
|
904
917
|
compact: false,
|
|
918
|
+
// trailingComma: true,
|
|
905
919
|
depth: 100,
|
|
906
920
|
colors: false,
|
|
907
921
|
maxArrayLength: Infinity,
|
|
908
922
|
maxStringLength: Infinity,
|
|
909
923
|
breakLength: Infinity,
|
|
910
924
|
numericSeparator: true
|
|
925
|
+
// strAbbreviateSize: 100000,
|
|
911
926
|
});
|
|
912
927
|
}
|
|
913
928
|
function serializeLines(key, lines) {
|
|
@@ -927,7 +942,9 @@ function getVariablesV2(contract, simnet, verbose) {
|
|
|
927
942
|
const fakeId = `${getContractName5(contract.contract_id)}-vars`;
|
|
928
943
|
logger.debug(`Deploying ${contract.contract_id} for variables.`);
|
|
929
944
|
if (!contract.source) {
|
|
930
|
-
logger.debug(
|
|
945
|
+
logger.debug(
|
|
946
|
+
`Contract ${getContractName5(contract.contract_id)} has no source. Skipping variables.`
|
|
947
|
+
);
|
|
931
948
|
return {};
|
|
932
949
|
}
|
|
933
950
|
if (contract.contract_interface.variables.length === 0) {
|
|
@@ -951,9 +968,14 @@ function getVariablesV2(contract, simnet, verbose) {
|
|
|
951
968
|
|
|
952
969
|
${varFn}`;
|
|
953
970
|
try {
|
|
954
|
-
const receipt = simnet.deployContract(
|
|
955
|
-
|
|
956
|
-
|
|
971
|
+
const receipt = simnet.deployContract(
|
|
972
|
+
fakeId,
|
|
973
|
+
fullSrc,
|
|
974
|
+
{
|
|
975
|
+
clarityVersion: 3
|
|
976
|
+
},
|
|
977
|
+
deployer
|
|
978
|
+
);
|
|
957
979
|
const result = receipt.result;
|
|
958
980
|
const varsAbi = {
|
|
959
981
|
tuple: []
|
|
@@ -1002,8 +1024,7 @@ function getContractTxs(batches) {
|
|
|
1002
1024
|
function getDeploymentContract(contractName, deployment) {
|
|
1003
1025
|
const txs = flatBatch(deployment.plan.batches);
|
|
1004
1026
|
for (const tx of txs) {
|
|
1005
|
-
if (!isContractTx(tx))
|
|
1006
|
-
continue;
|
|
1027
|
+
if (!isContractTx(tx)) continue;
|
|
1007
1028
|
if ("requirement-publish" in tx) {
|
|
1008
1029
|
const [_, name] = tx["requirement-publish"]["contract-id"].split(".");
|
|
1009
1030
|
if (name === contractName) {
|
|
@@ -1055,12 +1076,9 @@ function getIdentifier(tx) {
|
|
|
1055
1076
|
throw new Error(`Unable to find ID for contract.`);
|
|
1056
1077
|
}
|
|
1057
1078
|
function isContractTx(tx) {
|
|
1058
|
-
if ("contract-call" in tx)
|
|
1059
|
-
|
|
1060
|
-
if ("
|
|
1061
|
-
return false;
|
|
1062
|
-
if ("emulated-contract-call" in tx)
|
|
1063
|
-
return false;
|
|
1079
|
+
if ("contract-call" in tx) return false;
|
|
1080
|
+
if ("btc-transfer" in tx) return false;
|
|
1081
|
+
if ("emulated-contract-call" in tx) return false;
|
|
1064
1082
|
return true;
|
|
1065
1083
|
}
|
|
1066
1084
|
|
|
@@ -1074,16 +1092,18 @@ async function parseDeployment(path) {
|
|
|
1074
1092
|
}
|
|
1075
1093
|
var DEPLOYMENT_NETWORKS = ["devnet", "simnet", "testnet", "mainnet"];
|
|
1076
1094
|
async function getDeployments(config) {
|
|
1077
|
-
const entries = await Promise.all(
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1095
|
+
const entries = await Promise.all(
|
|
1096
|
+
DEPLOYMENT_NETWORKS.map(async (network) => {
|
|
1097
|
+
const file = `default.${network}-plan.yaml`;
|
|
1098
|
+
const path = join2(dirname3(config.clarinetFile()), "deployments", file);
|
|
1099
|
+
let plan;
|
|
1100
|
+
try {
|
|
1101
|
+
plan = await parseDeployment(path);
|
|
1102
|
+
} catch (_) {
|
|
1103
|
+
}
|
|
1104
|
+
return [network, plan];
|
|
1105
|
+
})
|
|
1106
|
+
);
|
|
1087
1107
|
return Object.fromEntries(entries);
|
|
1088
1108
|
}
|
|
1089
1109
|
async function generateESMFile({
|
|
@@ -1114,24 +1134,28 @@ function insertNetworkId(deployments, identifier, network) {
|
|
|
1114
1134
|
}
|
|
1115
1135
|
function collectContractDeployments(session, deployments, config) {
|
|
1116
1136
|
var _a;
|
|
1117
|
-
const full = Object.fromEntries(
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1137
|
+
const full = Object.fromEntries(
|
|
1138
|
+
sortContracts(session.contracts).map((contract) => {
|
|
1139
|
+
const contractName = getContractName6(contract.contract_id);
|
|
1140
|
+
const contractDeployments = Object.fromEntries(
|
|
1141
|
+
DEPLOYMENT_NETWORKS.map((network) => {
|
|
1142
|
+
const deployment = deployments[network];
|
|
1143
|
+
if (typeof deployment === "undefined") {
|
|
1144
|
+
return [network, null];
|
|
1145
|
+
}
|
|
1146
|
+
try {
|
|
1147
|
+
const contractName2 = contract.contract_id.split(".")[1];
|
|
1148
|
+
const tx = getDeploymentContract(contractName2, deployment);
|
|
1149
|
+
const id = getIdentifier(tx);
|
|
1150
|
+
return [network, id];
|
|
1151
|
+
} catch (_) {
|
|
1152
|
+
return [network, null];
|
|
1153
|
+
}
|
|
1154
|
+
})
|
|
1155
|
+
);
|
|
1156
|
+
return [contractName, contractDeployments];
|
|
1157
|
+
})
|
|
1158
|
+
);
|
|
1135
1159
|
const deployer = session.accounts.find((a) => a.name === "deployer");
|
|
1136
1160
|
(_a = config.clarinet.project.requirements) == null ? void 0 : _a.forEach(({ contract_id }) => {
|
|
1137
1161
|
insertNetworkId(full, contract_id, "mainnet");
|
|
@@ -1148,8 +1172,7 @@ function collectContractDeployments(session, deployments, config) {
|
|
|
1148
1172
|
return full;
|
|
1149
1173
|
}
|
|
1150
1174
|
function collectDeploymentFiles(deployments, clarinetFolder, cwd) {
|
|
1151
|
-
if (!deployments.simnet)
|
|
1152
|
-
return [];
|
|
1175
|
+
if (!deployments.simnet) return [];
|
|
1153
1176
|
const simnet = deployments.simnet;
|
|
1154
1177
|
const txs = getContractTxs(simnet.plan.batches);
|
|
1155
1178
|
const entries = txs.map((tx) => {
|
|
@@ -1164,8 +1187,7 @@ function collectDeploymentFiles(deployments, clarinetFolder, cwd) {
|
|
|
1164
1187
|
}
|
|
1165
1188
|
function generateSimnetCode(config, deployments, _session) {
|
|
1166
1189
|
var _a;
|
|
1167
|
-
if (!((_a = config.esm) == null ? void 0 : _a.include_accounts))
|
|
1168
|
-
return "";
|
|
1190
|
+
if (!((_a = config.esm) == null ? void 0 : _a.include_accounts)) return "";
|
|
1169
1191
|
const clarinetFolder = dirname3(config.clarinetFile());
|
|
1170
1192
|
const files = collectDeploymentFiles(deployments, clarinetFolder, config.cwd);
|
|
1171
1193
|
return `
|
|
@@ -1175,8 +1197,7 @@ export const simnetDeployment = ${JSON.stringify(files)};
|
|
|
1175
1197
|
async function afterESM(config) {
|
|
1176
1198
|
var _a;
|
|
1177
1199
|
const command = (_a = config.esm) == null ? void 0 : _a.after;
|
|
1178
|
-
if (!command)
|
|
1179
|
-
return;
|
|
1200
|
+
if (!command) return;
|
|
1180
1201
|
logger.debug(`Running after ESM command: ${command}`);
|
|
1181
1202
|
const parts = command.split(" ");
|
|
1182
1203
|
const [cmd, ...args] = parts;
|