@secondlayer/cli 9.0.1 → 9.0.2

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 CHANGED
@@ -12838,28 +12838,19 @@ var init_source3 = __esm(() => {
12838
12838
  class StacksApiClient {
12839
12839
  baseUrl;
12840
12840
  headers;
12841
- useProxy;
12842
- constructor(network = "mainnet", apiKey, apiUrl, slApiUrl) {
12843
- this.useProxy = !apiUrl && network !== "devnet";
12844
- if (this.useProxy) {
12845
- this.baseUrl = slApiUrl?.replace(/\/$/, "") || "";
12846
- this.headers = {};
12847
- } else {
12848
- this.baseUrl = apiUrl || process.env.STACKS_NODE_RPC_URL || "http://localhost:3999";
12849
- this.headers = apiKey ? { "x-api-key": apiKey } : {};
12850
- }
12841
+ constructor(_network = "mainnet", _apiKey, slApiUrl) {
12842
+ this.baseUrl = slApiUrl?.replace(/\/$/, "") || "";
12843
+ this.headers = {};
12851
12844
  }
12852
12845
  async ensureProxy() {
12853
- if (!this.useProxy || this.baseUrl)
12846
+ if (this.baseUrl)
12854
12847
  return;
12855
12848
  const { apiUrl, ephemeralKey } = await resolveAuth();
12856
12849
  this.baseUrl = apiUrl.replace(/\/$/, "");
12857
12850
  this.headers = { authorization: `Bearer ${ephemeralKey}` };
12858
12851
  }
12859
12852
  describeContractInfoSource() {
12860
- if (this.useProxy)
12861
- return "Secondlayer node";
12862
- return `Stacks node RPC at ${this.baseUrl}`;
12853
+ return "Secondlayer node";
12863
12854
  }
12864
12855
  async fetchWithErrorHandling(url, resourceType, resourceId) {
12865
12856
  try {
@@ -12882,24 +12873,12 @@ class StacksApiClient {
12882
12873
  }
12883
12874
  async getContractInfo(contractId) {
12884
12875
  await this.ensureProxy();
12885
- if (this.useProxy) {
12886
- const url2 = `${this.baseUrl}/v1/contracts/${encodeURIComponent(contractId)}?include=abi`;
12887
- const { contract } = await this.fetchWithErrorHandling(url2, "Contract", contractId);
12888
- if (!contract?.abi) {
12889
- throw new Error(`ABI not available for ${contractId} (status: ${contract?.abi_status ?? "unknown"})`);
12890
- }
12891
- return contract.abi;
12876
+ const url = `${this.baseUrl}/v1/contracts/${encodeURIComponent(contractId)}?include=abi`;
12877
+ const { contract } = await this.fetchWithErrorHandling(url, "Contract", contractId);
12878
+ if (!contract?.abi) {
12879
+ throw new Error(`ABI not available for ${contractId} (status: ${contract?.abi_status ?? "unknown"})`);
12892
12880
  }
12893
- const { address, contractName } = parseContractId(contractId);
12894
- const url = `${this.baseUrl}/v2/contracts/interface/${address}/${contractName}`;
12895
- return this.fetchWithErrorHandling(url, "Contract", contractId);
12896
- }
12897
- async getContractSource(contractId) {
12898
- const { address, contractName } = parseContractId(contractId);
12899
- const rpcUrl = process.env.STACKS_NODE_RPC_URL || this.baseUrl;
12900
- const url = `${rpcUrl}/v2/contracts/source/${address}/${contractName}`;
12901
- const data = await this.fetchWithErrorHandling(url, "Contract source", contractId);
12902
- return data.source;
12881
+ return contract.abi;
12903
12882
  }
12904
12883
  }
12905
12884
  var contractFetch;
@@ -31562,8 +31541,6 @@ var init_dependencies = __esm(() => {
31562
31541
  // src/commands/generate.ts
31563
31542
  var exports_generate = {};
31564
31543
  __export(exports_generate, {
31565
- resolveContracts: () => resolveContracts,
31566
- resolveContract: () => resolveContract,
31567
31544
  generate: () => generate
31568
31545
  });
31569
31546
  import path11 from "node:path";
@@ -31822,74 +31799,6 @@ async function watchAndRegenerate(files, options3) {
31822
31799
  }
31823
31800
  await new Promise(() => {});
31824
31801
  }
31825
- async function resolveContract(source, network, apiKey, apiUrl) {
31826
- if (source.source) {
31827
- const filePath = path11.resolve(process.cwd(), source.source);
31828
- const abi = await parseClarityFile(filePath);
31829
- const name = source.name || path11.basename(source.source, ".clar").replace(/-/g, "_").replace(/^\d/, "_$&");
31830
- const address = typeof source.address === "string" ? source.address : source.address?.[network] || DEFAULT_DEVNET_ADDRESS;
31831
- const { address: contractAddress, contractName } = address.includes(".") ? parseContractId(address) : { address, contractName: name };
31832
- return {
31833
- name,
31834
- address: contractAddress,
31835
- contractName: contractName || name,
31836
- abi,
31837
- source: "local"
31838
- };
31839
- }
31840
- if (source.address) {
31841
- const contractId = typeof source.address === "string" ? source.address : source.address[network];
31842
- if (!contractId) {
31843
- throw new Error(`No contract address for network ${network}`);
31844
- }
31845
- const contractInfo = await new StacksApiClient(network, apiKey, apiUrl).getContractInfo(contractId);
31846
- const abi = parseApiResponse(contractInfo);
31847
- const parsed = parseContractId(contractId);
31848
- const name = source.name || parsed.contractName.replace(/-/g, "_").replace(/^\d/, "_$&");
31849
- return {
31850
- name,
31851
- address: parsed.address,
31852
- contractName: parsed.contractName,
31853
- abi,
31854
- source: "api"
31855
- };
31856
- }
31857
- throw new Error("Contract must have either address or source");
31858
- }
31859
- async function resolveContracts(source, defaultNetwork, apiKey, apiUrl) {
31860
- if (typeof source.address === "string" || source.source) {
31861
- const resolved = await resolveContract(source, defaultNetwork || "testnet", apiKey, apiUrl);
31862
- return [resolved];
31863
- }
31864
- if (source.address && typeof source.address === "object") {
31865
- const resolvedContracts = [];
31866
- const networksToGenerate = defaultNetwork ? [defaultNetwork].filter((net3) => source.address[net3]) : Object.keys(source.address);
31867
- for (const network of networksToGenerate) {
31868
- const contractId = source.address[network];
31869
- if (!contractId)
31870
- continue;
31871
- try {
31872
- const networkApiClient = new StacksApiClient(network, apiKey, apiUrl);
31873
- const contractInfo = await networkApiClient.getContractInfo(contractId);
31874
- const abi = parseApiResponse(contractInfo);
31875
- const parsed = parseContractId(contractId);
31876
- const baseName = source.name || parsed.contractName.replace(/-/g, "_").replace(/^\d/, "_$&");
31877
- const name = network === "mainnet" ? baseName : `${network}${baseName.charAt(0).toUpperCase() + baseName.slice(1)}`;
31878
- resolvedContracts.push({
31879
- name,
31880
- address: parsed.address,
31881
- contractName: parsed.contractName,
31882
- abi,
31883
- source: "api"
31884
- });
31885
- } catch (error2) {
31886
- console.warn(`Warning: Failed to resolve contract for ${network}: ${getErrorMessage2(error2)}`);
31887
- }
31888
- }
31889
- return resolvedContracts;
31890
- }
31891
- throw new Error("Contract must have either address or source");
31892
- }
31893
31802
  var import_fast_glob, DEFAULT_DEVNET_ADDRESS = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM";
31894
31803
  var init_generate = __esm(() => {
31895
31804
  init_source4();
@@ -31920,7 +31829,7 @@ var {
31920
31829
  // package.json
31921
31830
  var package_default = {
31922
31831
  name: "@secondlayer/cli",
31923
- version: "9.0.1",
31832
+ version: "9.0.2",
31924
31833
  repository: {
31925
31834
  type: "git",
31926
31835
  url: "git+https://github.com/ryanwaits/secondlayer.git",
@@ -31972,7 +31881,7 @@ var package_default = {
31972
31881
  "@secondlayer/scaffold": "^1.4.0",
31973
31882
  "@secondlayer/sdk": "^6.23.1",
31974
31883
  "@secondlayer/shared": "^6.41.3",
31975
- "@secondlayer/stacks": "^2.11.0",
31884
+ "@secondlayer/stacks": "^2.14.0",
31976
31885
  "@secondlayer/subgraphs": "^3.19.6",
31977
31886
  "@biomejs/js-api": "^0.7.0",
31978
31887
  "@biomejs/wasm-nodejs": "^1.9.0",
@@ -38245,5 +38154,5 @@ registerAccountCommand(program);
38245
38154
  registerKeysCommand(program);
38246
38155
  program.parse();
38247
38156
 
38248
- //# debugId=E5EFFA52DC75DA5464756E2164756E21
38157
+ //# debugId=F6A10CCC90BD310564756E2164756E21
38249
38158
  //# sourceMappingURL=cli.js.map