@secondlayer/cli 0.3.10 → 1.0.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
@@ -16,7 +16,7 @@ interface ContractSource {
16
16
  */
17
17
  name?: string;
18
18
  }
19
- interface StacksConfig {
19
+ interface SecondLayerConfig {
20
20
  /**
21
21
  * Contracts to generate interfaces for (optional - plugins can provide these)
22
22
  */
@@ -57,7 +57,7 @@ interface ResolvedContract {
57
57
  /**
58
58
  * Core plugin interface that all plugins must implement
59
59
  */
60
- interface StacksCodegenPlugin {
60
+ interface SecondLayerPlugin {
61
61
  /** Plugin name (should be unique) */
62
62
  name: string;
63
63
  /** Plugin version */
@@ -80,13 +80,13 @@ interface StacksCodegenPlugin {
80
80
  /**
81
81
  * User configuration (before plugin transformations)
82
82
  */
83
- type UserConfig = StacksConfig;
83
+ type UserConfig = SecondLayerConfig;
84
84
  /**
85
85
  * Resolved configuration (after plugin transformations)
86
86
  */
87
- interface ResolvedConfig extends StacksConfig {
87
+ interface ResolvedConfig extends SecondLayerConfig {
88
88
  /** Resolved plugins array */
89
- plugins: StacksCodegenPlugin[];
89
+ plugins: SecondLayerPlugin[];
90
90
  }
91
91
  /**
92
92
  * Contract configuration that can be transformed by plugins
@@ -187,7 +187,7 @@ interface PluginUtils {
187
187
  /**
188
188
  * Plugin factory function type for creating plugins with options
189
189
  */
190
- type PluginFactory<TOptions = any> = (options?: TOptions) => StacksCodegenPlugin;
190
+ type PluginFactory<TOptions = any> = (options?: TOptions) => SecondLayerPlugin;
191
191
  /**
192
192
  * Plugin options base interface
193
193
  */
@@ -224,11 +224,11 @@ declare class PluginManager {
224
224
  /**
225
225
  * Register a plugin
226
226
  */
227
- register(plugin: StacksCodegenPlugin): void;
227
+ register(plugin: SecondLayerPlugin): void;
228
228
  /**
229
229
  * Get all registered plugins
230
230
  */
231
- getPlugins(): StacksCodegenPlugin[];
231
+ getPlugins(): SecondLayerPlugin[];
232
232
  /**
233
233
  * Transform user config through all plugins
234
234
  */
@@ -240,7 +240,7 @@ declare class PluginManager {
240
240
  /**
241
241
  * Execute lifecycle hooks
242
242
  */
243
- executeHook(hookName: keyof StacksCodegenPlugin, context: any): Promise<void>;
243
+ executeHook(hookName: keyof SecondLayerPlugin, context: any): Promise<void>;
244
244
  /**
245
245
  * Execute generation phase with full context
246
246
  */
@@ -352,5 +352,5 @@ declare function filterByOptions<T extends {
352
352
  /**
353
353
  * Utility function to create a simple plugin
354
354
  */
355
- declare function createPlugin(name: string, version: string, implementation: Partial<StacksCodegenPlugin>): StacksCodegenPlugin;
356
- export { testing, react, hasClarinetProject, filterByOptions, createPlugin, clarinet, actions, TestingPluginOptions, StacksCodegenPlugin, ReactPluginOptions, PluginUtils, PluginOptions, PluginManager, PluginFactory, PluginContext, Logger, GenerateContext, ClarinetPluginOptions, BasePluginOptions, ActionsPluginOptions };
355
+ declare function createPlugin(name: string, version: string, implementation: Partial<SecondLayerPlugin>): SecondLayerPlugin;
356
+ export { testing, react, hasClarinetProject, filterByOptions, createPlugin, clarinet, actions, TestingPluginOptions, SecondLayerPlugin, ReactPluginOptions, PluginUtils, PluginOptions, PluginManager, PluginFactory, PluginContext, Logger, GenerateContext, ClarinetPluginOptions, BasePluginOptions, ActionsPluginOptions };
package/dist/index.js CHANGED
@@ -1331,16 +1331,16 @@ ${indentedHelpersCode}
1331
1331
  init_format();
1332
1332
  async function generateProvider() {
1333
1333
  const code = `/**
1334
- * Generated Stacks React Provider
1334
+ * Generated SecondLayer React Provider
1335
1335
  * DO NOT EDIT MANUALLY
1336
1336
  */
1337
1337
 
1338
1338
  import React, { createContext, useContext } from 'react'
1339
1339
 
1340
1340
  /**
1341
- * Stacks configuration interface
1341
+ * SecondLayer configuration interface
1342
1342
  */
1343
- export interface StacksReactConfig {
1343
+ export interface SecondLayerReactConfig {
1344
1344
  /**
1345
1345
  * Network to use for API calls
1346
1346
  */
@@ -1365,21 +1365,21 @@ export interface StacksReactConfig {
1365
1365
  /**
1366
1366
  * Provider component props
1367
1367
  */
1368
- export interface StacksProviderProps {
1368
+ export interface SecondLayerProviderProps {
1369
1369
  children: React.ReactNode
1370
- config: StacksReactConfig
1370
+ config: SecondLayerReactConfig
1371
1371
  }
1372
1372
 
1373
1373
  /**
1374
- * React context for Stacks configuration
1374
+ * React context for SecondLayer configuration
1375
1375
  */
1376
- const StacksContext = createContext<StacksReactConfig | undefined>(undefined)
1377
- StacksContext.displayName = 'StacksContext'
1376
+ const SecondLayerContext = createContext<SecondLayerReactConfig | undefined>(undefined)
1377
+ SecondLayerContext.displayName = 'SecondLayerContext'
1378
1378
 
1379
1379
  /**
1380
- * Create a Stacks React configuration with defaults
1380
+ * Create a SecondLayer React configuration with defaults
1381
1381
  */
1382
- export function createStacksConfig(config: StacksReactConfig): StacksReactConfig {
1382
+ export function createSecondLayerConfig(config: SecondLayerReactConfig): SecondLayerReactConfig {
1383
1383
  return {
1384
1384
  network: config.network,
1385
1385
  apiKey: config.apiKey,
@@ -1389,31 +1389,31 @@ export function createStacksConfig(config: StacksReactConfig): StacksReactConfig
1389
1389
  }
1390
1390
 
1391
1391
  /**
1392
- * Provider component that makes Stacks configuration available to hooks
1392
+ * Provider component that makes SecondLayer configuration available to hooks
1393
1393
  */
1394
- export function StacksProvider({ children, config }: StacksProviderProps) {
1395
- const resolvedConfig = createStacksConfig(config)
1394
+ export function SecondLayerProvider({ children, config }: SecondLayerProviderProps) {
1395
+ const resolvedConfig = createSecondLayerConfig(config)
1396
1396
 
1397
1397
  return (
1398
- <StacksContext.Provider value={resolvedConfig}>
1398
+ <SecondLayerContext.Provider value={resolvedConfig}>
1399
1399
  {children}
1400
- </StacksContext.Provider>
1400
+ </SecondLayerContext.Provider>
1401
1401
  )
1402
1402
  }
1403
1403
 
1404
1404
  /**
1405
- * Hook to access the Stacks configuration
1405
+ * Hook to access the SecondLayer configuration
1406
1406
  */
1407
- export function useStacksConfig(): StacksReactConfig {
1408
- const context = useContext(StacksContext)
1409
-
1407
+ export function useSecondLayerConfig(): SecondLayerReactConfig {
1408
+ const context = useContext(SecondLayerContext)
1409
+
1410
1410
  if (context === undefined) {
1411
1411
  throw new Error(
1412
- 'useStacksConfig must be used within a StacksProvider. ' +
1413
- 'Make sure to wrap your app with <StacksProvider config={{...}}>'
1412
+ 'useSecondLayerConfig must be used within a SecondLayerProvider. ' +
1413
+ 'Make sure to wrap your app with <SecondLayerProvider config={{...}}>'
1414
1414
  )
1415
1415
  }
1416
-
1416
+
1417
1417
  return context
1418
1418
  }`;
1419
1419
  return formatCode(code);
@@ -1440,7 +1440,7 @@ async function generateGenericHooks(excludeList = []) {
1440
1440
  const hooksToGenerate = GENERIC_HOOKS.filter((hookName) => !excludeList.includes(hookName));
1441
1441
  const imports = `import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
1442
1442
  import { useState, useCallback } from 'react'
1443
- import { useStacksConfig } from './provider'
1443
+ import { useSecondLayerConfig } from './provider'
1444
1444
  import { connect, disconnect, isConnected, request, openContractCall as stacksOpenContractCall, openSTXTransfer, openSignatureRequestPopup, openContractDeploy } from '@stacks/connect'
1445
1445
  import { Cl, validateStacksAddress } from '@stacks/transactions'
1446
1446
  import type { PostCondition } from '@stacks/transactions'
@@ -1490,7 +1490,7 @@ function generateGenericHook(hookName) {
1490
1490
  switch (hookName) {
1491
1491
  case "useAccount":
1492
1492
  return `export function useAccount() {
1493
- const config = useStacksConfig()
1493
+ const config = useSecondLayerConfig()
1494
1494
 
1495
1495
  return useQuery({
1496
1496
  queryKey: ['stacks-account', config.network],
@@ -1633,7 +1633,7 @@ function generateGenericHook(hookName) {
1633
1633
  }`;
1634
1634
  case "useNetwork":
1635
1635
  return `export function useNetwork() {
1636
- const config = useStacksConfig()
1636
+ const config = useSecondLayerConfig()
1637
1637
 
1638
1638
  return useQuery({
1639
1639
  queryKey: ['stacks-network', config.network],
@@ -1660,7 +1660,7 @@ function generateGenericHook(hookName) {
1660
1660
  }`;
1661
1661
  case "useContract":
1662
1662
  return `export function useContract() {
1663
- const config = useStacksConfig()
1663
+ const config = useSecondLayerConfig()
1664
1664
  const queryClient = useQueryClient()
1665
1665
  const [isRequestPending, setIsRequestPending] = useState(false)
1666
1666
 
@@ -1955,7 +1955,7 @@ function generateGenericHook(hookName) {
1955
1955
  network?: 'mainnet' | 'testnet' | 'devnet';
1956
1956
  enabled?: boolean;
1957
1957
  }) {
1958
- const config = useStacksConfig()
1958
+ const config = useSecondLayerConfig()
1959
1959
 
1960
1960
  return useQuery<TResult>({
1961
1961
  queryKey: ['read-contract', params.contractAddress, params.contractName, params.functionName, params.args, params.network || config.network],
@@ -1993,7 +1993,7 @@ function generateGenericHook(hookName) {
1993
1993
  }`;
1994
1994
  case "useTransaction":
1995
1995
  return `export function useTransaction(txId?: string) {
1996
- const config = useStacksConfig()
1996
+ const config = useSecondLayerConfig()
1997
1997
 
1998
1998
  return useQuery({
1999
1999
  queryKey: ['transaction', txId, config.network],
@@ -2007,7 +2007,7 @@ function generateGenericHook(hookName) {
2007
2007
  }`;
2008
2008
  case "useBlock":
2009
2009
  return `export function useBlock(height?: number) {
2010
- const config = useStacksConfig()
2010
+ const config = useSecondLayerConfig()
2011
2011
 
2012
2012
  return useQuery({
2013
2013
  queryKey: ['block', height, config.network],
@@ -2021,7 +2021,7 @@ function generateGenericHook(hookName) {
2021
2021
  }`;
2022
2022
  case "useAccountTransactions":
2023
2023
  return `export function useAccountTransactions(address?: string) {
2024
- const config = useStacksConfig()
2024
+ const config = useSecondLayerConfig()
2025
2025
 
2026
2026
  return useQuery({
2027
2027
  queryKey: ['account-transactions', address, config.network],
@@ -2035,7 +2035,7 @@ function generateGenericHook(hookName) {
2035
2035
  }`;
2036
2036
  case "useWaitForTransaction":
2037
2037
  return `export function useWaitForTransaction(txId?: string) {
2038
- const config = useStacksConfig()
2038
+ const config = useSecondLayerConfig()
2039
2039
 
2040
2040
  return useQuery({
2041
2041
  queryKey: ['wait-for-transaction', txId, config.network],
@@ -2059,7 +2059,7 @@ function generateGenericHook(hookName) {
2059
2059
  }`;
2060
2060
  case "useOpenSTXTransfer":
2061
2061
  return `export function useOpenSTXTransfer() {
2062
- const config = useStacksConfig()
2062
+ const config = useSecondLayerConfig()
2063
2063
  const queryClient = useQueryClient()
2064
2064
 
2065
2065
  const mutation = useMutation({
@@ -2125,7 +2125,7 @@ function generateGenericHook(hookName) {
2125
2125
  }`;
2126
2126
  case "useSignMessage":
2127
2127
  return `export function useSignMessage() {
2128
- const config = useStacksConfig()
2128
+ const config = useSecondLayerConfig()
2129
2129
 
2130
2130
  const mutation = useMutation({
2131
2131
  mutationFn: async (params: {
@@ -2180,7 +2180,7 @@ function generateGenericHook(hookName) {
2180
2180
  }`;
2181
2181
  case "useDeployContract":
2182
2182
  return `export function useDeployContract() {
2183
- const config = useStacksConfig()
2183
+ const config = useSecondLayerConfig()
2184
2184
  const queryClient = useQueryClient()
2185
2185
 
2186
2186
  const mutation = useMutation({
@@ -2299,7 +2299,7 @@ function generateObjectArgs(args) {
2299
2299
  async function generateContractHooks(contracts, excludeList = []) {
2300
2300
  const imports = `import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
2301
2301
  import { useCallback } from 'react'
2302
- import { useStacksConfig } from './provider'
2302
+ import { useSecondLayerConfig } from './provider'
2303
2303
  import { request, openContractCall as stacksOpenContractCall } from '@stacks/connect'
2304
2304
  import type { PostCondition } from '@stacks/transactions'
2305
2305
  import { ${contracts.map((c) => c.name).join(", ")} } from './contracts'`;
@@ -2375,7 +2375,7 @@ function generateReadHook(func, contractName) {
2375
2375
  const enabledParam = func.args.length > 0 ? ", options?: { enabled?: boolean }" : "options?: { enabled?: boolean }";
2376
2376
  const returnType = clarityTypeToTS(func.outputs);
2377
2377
  return `export function ${hookName}(${argsSignature}${enabledParam}) {
2378
- const config = useStacksConfig()
2378
+ const config = useSecondLayerConfig()
2379
2379
 
2380
2380
  return useQuery<${returnType}>({
2381
2381
  queryKey: ['${func.name}', ${contractName}.address, ${generateQueryKeyArgs(func.args)}],
@@ -2392,7 +2392,7 @@ function generateWriteHook(func, contractName) {
2392
2392
  const hookName = `use${capitalize(contractName)}${capitalize(toCamelCase5(func.name))}`;
2393
2393
  const argsType = generateArgsType(func.args);
2394
2394
  return `export function ${hookName}() {
2395
- const config = useStacksConfig()
2395
+ const config = useSecondLayerConfig()
2396
2396
  const queryClient = useQueryClient()
2397
2397
 
2398
2398
  const mutation = useMutation({
@@ -2485,7 +2485,7 @@ function generateMapHook(map, contractVarName, _address, _contractName) {
2485
2485
  const keyType = clarityTypeToTS(map.key);
2486
2486
  const valueType = clarityTypeToTS(map.value);
2487
2487
  return `export function ${hookName}(key: ${keyType}, options?: { enabled?: boolean }) {
2488
- const config = useStacksConfig()
2488
+ const config = useSecondLayerConfig()
2489
2489
 
2490
2490
  return useQuery<${valueType} | null>({
2491
2491
  queryKey: ['${contractVarName}', '${map.name}', 'map', key, config.network],
@@ -2500,7 +2500,7 @@ function generateVarHook(variable, contractVarName, _address, _contractName) {
2500
2500
  const hookName = `use${capitalize(contractVarName)}${capitalize(toCamelCase5(variable.name))}`;
2501
2501
  const valueType = clarityTypeToTS(variable.type);
2502
2502
  return `export function ${hookName}(options?: { enabled?: boolean }) {
2503
- const config = useStacksConfig()
2503
+ const config = useSecondLayerConfig()
2504
2504
 
2505
2505
  return useQuery<${valueType}>({
2506
2506
  queryKey: ['${contractVarName}', '${variable.name}', 'var', config.network],
@@ -2515,7 +2515,7 @@ function generateConstantHook(constant, contractVarName, _address, _contractName
2515
2515
  const hookName = `use${capitalize(contractVarName)}${capitalize(toCamelCase5(constant.name))}`;
2516
2516
  const valueType = clarityTypeToTS(constant.type);
2517
2517
  return `export function ${hookName}(options?: { enabled?: boolean }) {
2518
- const config = useStacksConfig()
2518
+ const config = useSecondLayerConfig()
2519
2519
 
2520
2520
  return useQuery<${valueType}>({
2521
2521
  queryKey: ['${contractVarName}', '${constant.name}', 'constant', config.network],
@@ -2979,5 +2979,5 @@ export {
2979
2979
  PluginManager
2980
2980
  };
2981
2981
 
2982
- //# debugId=FE7B5594AE67250064756E2164756E21
2982
+ //# debugId=8AEF6558336586B764756E2164756E21
2983
2983
  //# sourceMappingURL=index.js.map