@secondlayer/cli 1.0.0 → 1.2.0

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.d.ts CHANGED
@@ -303,6 +303,8 @@ interface ActionsPluginOptions {
303
303
  excludeFunctions?: string[];
304
304
  /** Enable debug output */
305
305
  debug?: boolean;
306
+ /** Environment variable name for default sender key (default: "STX_SENDER_KEY") */
307
+ senderKeyEnv?: string;
306
308
  }
307
309
  /**
308
310
  * Actions plugin factory
package/dist/index.js CHANGED
@@ -30,23 +30,53 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
30
  // src/utils/format.ts
31
31
  var exports_format = {};
32
32
  __export(exports_format, {
33
- formatCode: () => formatCode,
34
- PRETTIER_OPTIONS: () => PRETTIER_OPTIONS
33
+ formatCode: () => formatCode
35
34
  });
36
- import { format } from "prettier";
35
+ import { Biome, Distribution } from "@biomejs/js-api";
36
+ async function getBiome() {
37
+ if (!biome) {
38
+ biome = await Biome.create({
39
+ distribution: Distribution.NODE
40
+ });
41
+ biome.applyConfiguration({
42
+ formatter: {
43
+ enabled: true,
44
+ indentStyle: "tab",
45
+ lineWidth: 80
46
+ },
47
+ javascript: {
48
+ formatter: {
49
+ semicolons: "always",
50
+ quoteStyle: "single"
51
+ }
52
+ },
53
+ organizeImports: {
54
+ enabled: true
55
+ },
56
+ linter: {
57
+ enabled: true
58
+ },
59
+ assists: {
60
+ enabled: true
61
+ }
62
+ });
63
+ biome.registerProjectFolder();
64
+ }
65
+ return biome;
66
+ }
37
67
  async function formatCode(code) {
38
- return format(code, PRETTIER_OPTIONS);
39
- }
40
- var PRETTIER_OPTIONS;
41
- var init_format = __esm(() => {
42
- PRETTIER_OPTIONS = {
43
- parser: "typescript",
44
- singleQuote: true,
45
- semi: true,
46
- printWidth: 100,
47
- trailingComma: "es5"
48
- };
49
- });
68
+ const b = await getBiome();
69
+ const linted = b.lintContent(code, {
70
+ filePath: "generated.ts",
71
+ fixFileMode: "SafeFixes"
72
+ });
73
+ const formatted = b.formatContent(linted.content, {
74
+ filePath: "generated.ts"
75
+ });
76
+ return formatted.content;
77
+ }
78
+ var biome = null;
79
+ var init_format = () => {};
50
80
 
51
81
  // src/core/plugin-manager.ts
52
82
  import { promises as fs } from "fs";
@@ -1174,6 +1204,7 @@ function generateReadHelpers(contract, options) {
1174
1204
  function generateWriteHelpers(contract, options) {
1175
1205
  const { abi, name } = contract;
1176
1206
  const functions = abi.functions || [];
1207
+ const envVarName = options.senderKeyEnv ?? "STX_SENDER_KEY";
1177
1208
  const publicFunctions = functions.filter((f) => f.access === "public");
1178
1209
  if (publicFunctions.length === 0) {
1179
1210
  return "";
@@ -1194,8 +1225,7 @@ function generateWriteHelpers(contract, options) {
1194
1225
  const methodName = toCamelCase4(func.name);
1195
1226
  const argsSignature = generateArgsSignature(func.args);
1196
1227
  const clarityArgs = generateClarityArgs(func.args, name);
1197
- return `async ${methodName}(${argsSignature}options: {
1198
- senderKey: string;
1228
+ return `async ${methodName}(${argsSignature}senderKey?: string, options?: {
1199
1229
  network?: 'mainnet' | 'testnet' | 'devnet';
1200
1230
  fee?: string | number | undefined;
1201
1231
  nonce?: bigint;
@@ -1203,14 +1233,18 @@ function generateWriteHelpers(contract, options) {
1203
1233
  postConditions?: PostCondition[];
1204
1234
  validateWithAbi?: boolean;
1205
1235
  }) {
1206
- const { senderKey, network = 'mainnet', ...txOptions } = options;
1207
-
1236
+ const resolvedSenderKey = senderKey ?? process.env.${envVarName};
1237
+ if (!resolvedSenderKey) {
1238
+ throw new Error('senderKey required: pass as argument or set ${envVarName} env var');
1239
+ }
1240
+ const { network = 'mainnet', ...txOptions } = options ?? {};
1241
+
1208
1242
  return await makeContractCall({
1209
1243
  contractAddress: '${contract.address}',
1210
1244
  contractName: '${contract.contractName}',
1211
1245
  functionName: '${func.name}',
1212
1246
  functionArgs: [${clarityArgs}],
1213
- senderKey,
1247
+ senderKey: resolvedSenderKey,
1214
1248
  network,
1215
1249
  validateWithAbi: true,
1216
1250
  ...txOptions
@@ -2979,5 +3013,5 @@ export {
2979
3013
  PluginManager
2980
3014
  };
2981
3015
 
2982
- //# debugId=8AEF6558336586B764756E2164756E21
3016
+ //# debugId=161C0B3D172075E364756E2164756E21
2983
3017
  //# sourceMappingURL=index.js.map