@secondlayer/cli 8.14.2 → 8.14.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/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/plugins/index.js +41 -48
- package/dist/plugins/index.js.map +12 -10
- package/package.json +2 -2
package/dist/plugins/index.js
CHANGED
|
@@ -558,6 +558,21 @@ init_plugin_manager();
|
|
|
558
558
|
init_contract();
|
|
559
559
|
import { initSimnet } from "@hirosystems/clarinet-sdk";
|
|
560
560
|
import { toCamelCase as toCamelCase2 } from "@secondlayer/stacks/clarity";
|
|
561
|
+
|
|
562
|
+
// src/utils/constants.ts
|
|
563
|
+
var DEFAULT_SENDER_ADDRESS = "SP000000000000000000002Q6VF78";
|
|
564
|
+
// src/plugins/shared.ts
|
|
565
|
+
function matchesContractFilters(name, options) {
|
|
566
|
+
if (options.include && !options.include.includes(name)) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
if (options.exclude?.includes(name)) {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// src/plugins/clarinet/index.ts
|
|
561
576
|
function sanitizeContractName(name) {
|
|
562
577
|
return toCamelCase2(name);
|
|
563
578
|
}
|
|
@@ -576,7 +591,7 @@ async function isUserDefinedContract(contractId, manifestPath) {
|
|
|
576
591
|
if (userContracts.has(contractName)) {
|
|
577
592
|
return true;
|
|
578
593
|
}
|
|
579
|
-
} catch
|
|
594
|
+
} catch {}
|
|
580
595
|
const systemContractPatterns = [
|
|
581
596
|
/^pox-\d+$/,
|
|
582
597
|
/^bns$/,
|
|
@@ -587,7 +602,7 @@ async function isUserDefinedContract(contractId, manifestPath) {
|
|
|
587
602
|
return false;
|
|
588
603
|
}
|
|
589
604
|
const systemAddresses = [
|
|
590
|
-
|
|
605
|
+
DEFAULT_SENDER_ADDRESS,
|
|
591
606
|
"ST000000000000000000002AMW42H"
|
|
592
607
|
];
|
|
593
608
|
if (systemAddresses.includes(address)) {
|
|
@@ -614,10 +629,7 @@ var clarinet = (options = {}) => {
|
|
|
614
629
|
}
|
|
615
630
|
continue;
|
|
616
631
|
}
|
|
617
|
-
if (
|
|
618
|
-
continue;
|
|
619
|
-
}
|
|
620
|
-
if (options.exclude?.includes(contractName)) {
|
|
632
|
+
if (!matchesContractFilters(contractName, options)) {
|
|
621
633
|
continue;
|
|
622
634
|
}
|
|
623
635
|
const sanitizedName = sanitizeContractName(contractName);
|
|
@@ -637,8 +649,10 @@ var clarinet = (options = {}) => {
|
|
|
637
649
|
};
|
|
638
650
|
} catch (error) {
|
|
639
651
|
const err = error;
|
|
640
|
-
if (
|
|
641
|
-
console.warn(`⚠️ Clarinet plugin failed to load contracts: ${err.message}`);
|
|
652
|
+
if (await hasClarinetProject(manifestPath)) {
|
|
653
|
+
console.warn(`⚠️ Clarinet plugin: found ${manifestPath} but failed to load contracts: ${err.message}`);
|
|
654
|
+
} else if (options.debug) {
|
|
655
|
+
console.warn(`⚠️ Clarinet plugin: no manifest at ${manifestPath}, skipping`);
|
|
642
656
|
}
|
|
643
657
|
return config;
|
|
644
658
|
}
|
|
@@ -680,14 +694,8 @@ import {
|
|
|
680
694
|
} from "@secondlayer/scaffold";
|
|
681
695
|
|
|
682
696
|
// src/plugins/actions/generators.ts
|
|
683
|
-
function
|
|
684
|
-
|
|
685
|
-
const functions = abi.functions || [];
|
|
686
|
-
const readOnlyFunctions = functions.filter((f) => f.access === "read-only");
|
|
687
|
-
if (readOnlyFunctions.length === 0) {
|
|
688
|
-
return "";
|
|
689
|
-
}
|
|
690
|
-
const filteredFunctions = readOnlyFunctions.filter((func) => {
|
|
697
|
+
function applyFunctionFilters(functions, options) {
|
|
698
|
+
return functions.filter((func) => {
|
|
691
699
|
if (options.includeFunctions && !options.includeFunctions.includes(func.name)) {
|
|
692
700
|
return false;
|
|
693
701
|
}
|
|
@@ -696,6 +704,15 @@ function generateReadHelpers(contract, options) {
|
|
|
696
704
|
}
|
|
697
705
|
return true;
|
|
698
706
|
});
|
|
707
|
+
}
|
|
708
|
+
function generateReadHelpers(contract, options) {
|
|
709
|
+
const { abi } = contract;
|
|
710
|
+
const functions = abi.functions || [];
|
|
711
|
+
const readOnlyFunctions = functions.filter((f) => f.access === "read-only");
|
|
712
|
+
if (readOnlyFunctions.length === 0) {
|
|
713
|
+
return "";
|
|
714
|
+
}
|
|
715
|
+
const filteredFunctions = applyFunctionFilters(readOnlyFunctions, options);
|
|
699
716
|
if (filteredFunctions.length === 0) {
|
|
700
717
|
return "";
|
|
701
718
|
}
|
|
@@ -713,7 +730,7 @@ function generateReadHelpers(contract, options) {
|
|
|
713
730
|
functionName: '${func.name}',
|
|
714
731
|
functionArgs: [${clarityArgs}],
|
|
715
732
|
network: options?.network ?? inferNetworkFromAddress('${contract.address}') ?? 'mainnet',
|
|
716
|
-
senderAddress: options?.senderAddress || '
|
|
733
|
+
senderAddress: options?.senderAddress || '${DEFAULT_SENDER_ADDRESS}'
|
|
717
734
|
});
|
|
718
735
|
}`;
|
|
719
736
|
});
|
|
@@ -731,15 +748,7 @@ function generateWriteHelpers(contract, options) {
|
|
|
731
748
|
if (publicFunctions.length === 0) {
|
|
732
749
|
return "";
|
|
733
750
|
}
|
|
734
|
-
const filteredFunctions = publicFunctions
|
|
735
|
-
if (options.includeFunctions && !options.includeFunctions.includes(func.name)) {
|
|
736
|
-
return false;
|
|
737
|
-
}
|
|
738
|
-
if (options.excludeFunctions?.includes(func.name)) {
|
|
739
|
-
return false;
|
|
740
|
-
}
|
|
741
|
-
return true;
|
|
742
|
-
});
|
|
751
|
+
const filteredFunctions = applyFunctionFilters(publicFunctions, options);
|
|
743
752
|
if (filteredFunctions.length === 0) {
|
|
744
753
|
return "";
|
|
745
754
|
}
|
|
@@ -798,15 +807,7 @@ var actions = (options = {}) => {
|
|
|
798
807
|
version: "1.0.0",
|
|
799
808
|
async generate(context) {
|
|
800
809
|
const { contracts } = context;
|
|
801
|
-
const filteredContracts = contracts.filter((contract) =>
|
|
802
|
-
if (options.include && !options.include.includes(contract.name)) {
|
|
803
|
-
return false;
|
|
804
|
-
}
|
|
805
|
-
if (options.exclude?.includes(contract.name)) {
|
|
806
|
-
return false;
|
|
807
|
-
}
|
|
808
|
-
return true;
|
|
809
|
-
});
|
|
810
|
+
const filteredContracts = contracts.filter((contract) => matchesContractFilters(contract.name, options));
|
|
810
811
|
if (filteredContracts.length === 0) {
|
|
811
812
|
if (options.debug) {
|
|
812
813
|
context.logger.debug("Actions plugin: No contracts to process");
|
|
@@ -1020,7 +1021,7 @@ function generateReadHook(func, contractName) {
|
|
|
1020
1021
|
queryKey: ['${func.name}', ${contractName}.address, ${generateArgNames(func.args)}],
|
|
1021
1022
|
queryFn: () => ${contractName}.read.${toCamelCase4(func.name)}(${generateArgNames(func.args) ? `{ ${generateObjectArgs(func.args)} }, ` : ""}{
|
|
1022
1023
|
network: config.network,
|
|
1023
|
-
senderAddress: config.senderAddress || '
|
|
1024
|
+
senderAddress: config.senderAddress || '${DEFAULT_SENDER_ADDRESS}'
|
|
1024
1025
|
}),
|
|
1025
1026
|
${func.args.length > 0 ? `enabled: ${generateEnabledCondition(func.args)} && (options?.enabled ?? true),` : ""}
|
|
1026
1027
|
...options
|
|
@@ -1642,7 +1643,7 @@ function generateGenericHook(hookName) {
|
|
|
1642
1643
|
functionName: params.functionName,
|
|
1643
1644
|
functionArgs,
|
|
1644
1645
|
network: params.network || config.network || 'mainnet',
|
|
1645
|
-
senderAddress: config.senderAddress || '
|
|
1646
|
+
senderAddress: config.senderAddress || '${DEFAULT_SENDER_ADDRESS}'
|
|
1646
1647
|
}) as TResult
|
|
1647
1648
|
},
|
|
1648
1649
|
enabled: params.enabled ?? true
|
|
@@ -1910,7 +1911,7 @@ export function createSecondLayerConfig(config: SecondLayerReactConfig): SecondL
|
|
|
1910
1911
|
network: config.network,
|
|
1911
1912
|
apiKey: config.apiKey,
|
|
1912
1913
|
apiUrl: config.apiUrl,
|
|
1913
|
-
senderAddress: config.senderAddress || '
|
|
1914
|
+
senderAddress: config.senderAddress || '${DEFAULT_SENDER_ADDRESS}'
|
|
1914
1915
|
}
|
|
1915
1916
|
}
|
|
1916
1917
|
|
|
@@ -2181,15 +2182,7 @@ var testing = (options = {}) => {
|
|
|
2181
2182
|
version: "1.0.0",
|
|
2182
2183
|
async generate(context) {
|
|
2183
2184
|
const { contracts } = context;
|
|
2184
|
-
const filteredContracts = contracts.filter((contract) =>
|
|
2185
|
-
if (options.include && !options.include.includes(contract.name)) {
|
|
2186
|
-
return false;
|
|
2187
|
-
}
|
|
2188
|
-
if (options.exclude?.includes(contract.name)) {
|
|
2189
|
-
return false;
|
|
2190
|
-
}
|
|
2191
|
-
return true;
|
|
2192
|
-
});
|
|
2185
|
+
const filteredContracts = contracts.filter((contract) => matchesContractFilters(contract.name, options));
|
|
2193
2186
|
if (filteredContracts.length === 0) {
|
|
2194
2187
|
if (options.debug) {
|
|
2195
2188
|
context.logger.debug("Testing plugin: No contracts to process");
|
|
@@ -2242,5 +2235,5 @@ export {
|
|
|
2242
2235
|
PluginManager
|
|
2243
2236
|
};
|
|
2244
2237
|
|
|
2245
|
-
//# debugId=
|
|
2238
|
+
//# debugId=B22EAFB44071D00264756E2164756E21
|
|
2246
2239
|
//# sourceMappingURL=index.js.map
|