@conto_finance/create-conto-agent 0.1.1 → 0.3.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.
@@ -56,7 +56,7 @@ function printTable(headers, rows, options) {
56
56
  console.log(table.toString());
57
57
  }
58
58
  function printAmount(amount, currency) {
59
- if (currency === "pathUSD" || currency === "USDC") {
59
+ if (currency === "pathUSD" || currency === "USDC" || currency === "USDC.e") {
60
60
  return `$${amount.toFixed(2)} ${currency}`;
61
61
  }
62
62
  return `${amount} ${currency}`;
@@ -4,10 +4,17 @@ import path from "path";
4
4
  import os from "os";
5
5
  var CONTO_DIR = path.join(os.homedir(), ".conto");
6
6
  var CONFIG_FILE = path.join(CONTO_DIR, "config.json");
7
+ var PRIVATE_DIR_MODE = 448;
8
+ var PRIVATE_FILE_MODE = 384;
7
9
  function ensureContoDir() {
8
10
  if (!fs.existsSync(CONTO_DIR)) {
9
- fs.mkdirSync(CONTO_DIR, { recursive: true });
11
+ fs.mkdirSync(CONTO_DIR, { recursive: true, mode: PRIVATE_DIR_MODE });
10
12
  }
13
+ fs.chmodSync(CONTO_DIR, PRIVATE_DIR_MODE);
14
+ }
15
+ function writePrivateFile(filePath, content) {
16
+ fs.writeFileSync(filePath, content, { mode: PRIVATE_FILE_MODE });
17
+ fs.chmodSync(filePath, PRIVATE_FILE_MODE);
11
18
  }
12
19
  function loadGlobalConfig() {
13
20
  try {
@@ -21,7 +28,7 @@ function loadGlobalConfig() {
21
28
  }
22
29
  function saveGlobalConfig(config) {
23
30
  ensureContoDir();
24
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n");
31
+ writePrivateFile(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n");
25
32
  }
26
33
  function loadProjectEnv(dir) {
27
34
  const envPath = path.join(dir || process.cwd(), ".env.local");
@@ -53,10 +60,12 @@ function loadConfig() {
53
60
  testnet: global.network?.testnet || env.CONTO_CHAIN_ID === "42431"
54
61
  };
55
62
  }
56
- function writeEnvLocal(dir, vars) {
57
- const lines = Object.entries(vars).map(([key, value]) => `${key}=${value}`);
63
+ function writeEnvLocal(dir, entries) {
64
+ const lines = entries.map(
65
+ (entry) => typeof entry === "string" ? entry : `${entry[0]}=${entry[1]}`
66
+ );
58
67
  const content = lines.join("\n") + "\n";
59
- fs.writeFileSync(path.join(dir, ".env.local"), content);
68
+ writePrivateFile(path.join(dir, ".env.local"), content);
60
69
  }
61
70
  function writeContoConfig(dir, config) {
62
71
  fs.writeFileSync(path.join(dir, "conto.config.json"), JSON.stringify(config, null, 2) + "\n");