@secondlayer/cli 0.3.1 → 0.3.3

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.js CHANGED
@@ -128,10 +128,12 @@ class PluginManager {
128
128
  }
129
129
  }
130
130
  if (contract.abi) {
131
+ const addressStr = typeof contract.address === "string" ? contract.address : "";
132
+ const [contractAddress, originalContractName] = addressStr.split(".");
131
133
  const processed = {
132
- name: contract.name || "unknown",
133
- address: typeof contract.address === "string" ? contract.address.split(".")[0] : "unknown",
134
- contractName: contract.name || "unknown",
134
+ name: contract.name || originalContractName || "unknown",
135
+ address: contractAddress || "unknown",
136
+ contractName: originalContractName || contract.name || "unknown",
135
137
  abi: contract.abi,
136
138
  source: "api",
137
139
  metadata: contract.metadata
@@ -352,6 +354,8 @@ async function generateContractInterface(contracts) {
352
354
  const header = `/**
353
355
  * Generated by @secondlayer/cli
354
356
  * DO NOT EDIT MANUALLY
357
+ *
358
+ * @requires @stacks/transactions - Install with: npm install @stacks/transactions
355
359
  */`;
356
360
  const networkUtils = generateNetworkUtils();
357
361
  const contractsCode = contracts.map((contract) => generateContract(contract)).join(`
@@ -520,9 +524,8 @@ function generateClarityConversion(argName, argType) {
520
524
  }
521
525
  if (${argName}.includes(".")) {
522
526
  return Cl.contractPrincipal(address, contractName);
523
- } else {
524
- return Cl.standardPrincipal(${argName});
525
527
  }
528
+ return Cl.standardPrincipal(${argName});
526
529
  })()`;
527
530
  default:
528
531
  return `${argName}`;
@@ -560,8 +563,9 @@ function generateClarityConversion(argName, argType) {
560
563
  if (value.startsWith('0x') || /^[0-9a-fA-F]+$/.test(value)) {
561
564
  return Cl.bufferFromHex(value);
562
565
  }
563
- // Check for non-ASCII characters (UTF-8)
564
- if (!/^[\\x00-\\x7F]*$/.test(value)) {
566
+ // Check for non-ASCII characters (UTF-8) using char code comparison
567
+ const hasNonAscii = value.split('').some(char => char.charCodeAt(0) > 127);
568
+ if (hasNonAscii) {
565
569
  return Cl.bufferFromUtf8(value);
566
570
  }
567
571
  // Default to ASCII for simple ASCII strings
@@ -934,9 +938,8 @@ function generateClarityConversion2(argName, argType) {
934
938
  }
935
939
  if (${argName}.includes(".")) {
936
940
  return Cl.contractPrincipal(address, contractName);
937
- } else {
938
- return Cl.standardPrincipal(${argName});
939
941
  }
942
+ return Cl.standardPrincipal(${argName});
940
943
  })()`;
941
944
  default:
942
945
  return `${argName}`;
@@ -970,7 +973,8 @@ function generateClarityConversion2(argName, argType) {
970
973
  if (value.startsWith('0x') || /^[0-9a-fA-F]+$/.test(value)) {
971
974
  return Cl.bufferFromHex(value);
972
975
  }
973
- if (!/^[\\x00-\\x7F]*$/.test(value)) {
976
+ const hasNonAscii = value.split('').some(char => char.charCodeAt(0) > 127);
977
+ if (hasNonAscii) {
974
978
  return Cl.bufferFromUtf8(value);
975
979
  }
976
980
  return Cl.bufferFromAscii(value);
@@ -2919,5 +2923,5 @@ export {
2919
2923
  PluginManager
2920
2924
  };
2921
2925
 
2922
- //# debugId=7F2D601996EE7CEE64756E2164756E21
2926
+ //# debugId=AA54807E287F170A64756E2164756E21
2923
2927
  //# sourceMappingURL=index.js.map