@secondlayer/cli 0.3.2 → 0.3.4
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/cli.js +12 -23
- package/dist/cli.js.map +4 -4
- package/dist/index.js +6 -4
- package/dist/index.js.map +3 -3
- package/dist/plugin-manager.js +6 -4
- package/dist/plugin-manager.js.map +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7650,10 +7650,12 @@ class PluginManager {
|
|
|
7650
7650
|
}
|
|
7651
7651
|
}
|
|
7652
7652
|
if (contract.abi) {
|
|
7653
|
+
const addressStr = typeof contract.address === "string" ? contract.address : "";
|
|
7654
|
+
const [contractAddress, originalContractName] = addressStr.split(".");
|
|
7653
7655
|
const processed = {
|
|
7654
|
-
name: contract.name || "unknown",
|
|
7655
|
-
address:
|
|
7656
|
-
contractName: contract.name || "unknown",
|
|
7656
|
+
name: contract.name || originalContractName || "unknown",
|
|
7657
|
+
address: contractAddress || "unknown",
|
|
7658
|
+
contractName: originalContractName || contract.name || "unknown",
|
|
7657
7659
|
abi: contract.abi,
|
|
7658
7660
|
source: "api",
|
|
7659
7661
|
metadata: contract.metadata
|
|
@@ -27839,7 +27841,7 @@ function deriveContractName(filePath) {
|
|
|
27839
27841
|
function toCamelCase2(str) {
|
|
27840
27842
|
return str.replace(/[-_](.)/g, (_2, char) => char.toUpperCase()).replace(/^(.)/, (_2, char) => char.toLowerCase()).replace(/^\d/, "_$&");
|
|
27841
27843
|
}
|
|
27842
|
-
async function buildConfigFromInputs(parsedInputs, outPath, apiKey
|
|
27844
|
+
async function buildConfigFromInputs(parsedInputs, outPath, apiKey) {
|
|
27843
27845
|
const contracts = [];
|
|
27844
27846
|
for (const file of parsedInputs.files) {
|
|
27845
27847
|
const abi = await parseClarityFile(file);
|
|
@@ -27854,7 +27856,6 @@ async function buildConfigFromInputs(parsedInputs, outPath, apiKey, log) {
|
|
|
27854
27856
|
for (const contractId of parsedInputs.contractIds) {
|
|
27855
27857
|
const [address, contractName] = contractId.split(".");
|
|
27856
27858
|
const network = inferNetwork(address);
|
|
27857
|
-
log(`Fetching ${contractName} from ${network}...`);
|
|
27858
27859
|
try {
|
|
27859
27860
|
const apiClient = new StacksApiClient(network, apiKey);
|
|
27860
27861
|
const contractInfo = await apiClient.getContractInfo(contractId);
|
|
@@ -27877,7 +27878,6 @@ async function buildConfigFromInputs(parsedInputs, outPath, apiKey, log) {
|
|
|
27877
27878
|
};
|
|
27878
27879
|
}
|
|
27879
27880
|
async function generate(files, options3) {
|
|
27880
|
-
const log = (msg) => console.log(source_default.gray(` ${msg}`));
|
|
27881
27881
|
try {
|
|
27882
27882
|
let config;
|
|
27883
27883
|
if (files && files.length > 0) {
|
|
@@ -27899,9 +27899,8 @@ Examples:`));
|
|
|
27899
27899
|
No .clar files or contract addresses matched the provided inputs`));
|
|
27900
27900
|
process.exit(1);
|
|
27901
27901
|
}
|
|
27902
|
-
log(`Processing ${totalInputs} contract(s)...`);
|
|
27903
27902
|
const apiKey = options3.apiKey || process.env.HIRO_API_KEY;
|
|
27904
|
-
config = await buildConfigFromInputs(parsedInputs, options3.out, apiKey
|
|
27903
|
+
config = await buildConfigFromInputs(parsedInputs, options3.out, apiKey);
|
|
27905
27904
|
} else {
|
|
27906
27905
|
config = await loadConfig(options3.config);
|
|
27907
27906
|
}
|
|
@@ -27921,7 +27920,8 @@ No .clar files or contract addresses matched the provided inputs`));
|
|
|
27921
27920
|
address: contract.address,
|
|
27922
27921
|
source: contract.source,
|
|
27923
27922
|
abi: contract.abi,
|
|
27924
|
-
_clarinetSource: contract._clarinetSource
|
|
27923
|
+
_clarinetSource: contract._clarinetSource,
|
|
27924
|
+
_directFile: contract._directFile
|
|
27925
27925
|
}));
|
|
27926
27926
|
const processedContracts = await pluginManager.transformContracts(contractConfigs, resolvedConfig);
|
|
27927
27927
|
if (processedContracts.length === 0) {
|
|
@@ -27946,18 +27946,7 @@ To get started:`);
|
|
|
27946
27946
|
await checkBaseDependencies(process.cwd());
|
|
27947
27947
|
const contractCount = processedContracts.length;
|
|
27948
27948
|
const contractWord = contractCount === 1 ? "contract" : "contracts";
|
|
27949
|
-
console.log(source_default.green(`✓
|
|
27950
|
-
console.log(`
|
|
27951
|
-
\uD83D\uDCC4 ${config.out}`);
|
|
27952
|
-
console.log(`
|
|
27953
|
-
\uD83D\uDCA1 Import your contracts:`);
|
|
27954
|
-
if (processedContracts.length > 0) {
|
|
27955
|
-
const exampleContract = processedContracts[0];
|
|
27956
|
-
console.log(source_default.gray(` import { ${exampleContract.name} } from '${config.out.replace(/\.ts$/, "")}'`));
|
|
27957
|
-
if (processedContracts.length > 1) {
|
|
27958
|
-
console.log(source_default.gray(` // Also available: ${processedContracts.slice(1).map((c4) => c4.name).join(", ")}`));
|
|
27959
|
-
}
|
|
27960
|
-
}
|
|
27949
|
+
console.log(source_default.green(`✓ Generated \`${config.out}\` for ${contractCount} ${contractWord}`));
|
|
27961
27950
|
} catch (error) {
|
|
27962
27951
|
console.error(source_default.red("✗ Generation failed"));
|
|
27963
27952
|
console.error(source_default.red(`
|
|
@@ -28116,7 +28105,7 @@ var {
|
|
|
28116
28105
|
// package.json
|
|
28117
28106
|
var package_default = {
|
|
28118
28107
|
name: "@secondlayer/cli",
|
|
28119
|
-
version: "0.3.
|
|
28108
|
+
version: "0.3.4",
|
|
28120
28109
|
description: "CLI for generating type-safe contract interfaces for the Stacks blockchain",
|
|
28121
28110
|
type: "module",
|
|
28122
28111
|
bin: {
|
|
@@ -28192,5 +28181,5 @@ program.command("init").description("Initialize a new stacks.config.ts file").ac
|
|
|
28192
28181
|
});
|
|
28193
28182
|
program.parse();
|
|
28194
28183
|
|
|
28195
|
-
//# debugId=
|
|
28184
|
+
//# debugId=3784DD59298C867364756E2164756E21
|
|
28196
28185
|
//# sourceMappingURL=cli.js.map
|