@secondlayer/cli 8.4.1 → 8.4.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
@@ -32354,7 +32354,7 @@ var {
32354
32354
  // package.json
32355
32355
  var package_default = {
32356
32356
  name: "@secondlayer/cli",
32357
- version: "8.4.1",
32357
+ version: "8.4.2",
32358
32358
  repository: {
32359
32359
  type: "git",
32360
32360
  url: "git+https://github.com/ryanwaits/secondlayer.git",
@@ -33774,10 +33774,22 @@ function shellQuote(value) {
33774
33774
  }
33775
33775
  function buildSubscriptionTestFixture(input2) {
33776
33776
  const nowSeconds = input2.nowSeconds ?? Math.floor(Date.now() / 1000);
33777
+ const sub = input2.subscription;
33778
+ const isChain = sub.kind === "chain";
33779
+ const type = isChain ? `chain.${sub.triggers?.[0]?.type ?? "event"}.apply` : `${sub.subgraphName}.${sub.tableName}.created`;
33780
+ const data = isChain ? {
33781
+ action: "apply",
33782
+ canonical: true,
33783
+ block_hash: "0xexampleblock",
33784
+ block_height: 0,
33785
+ tx_id: input2.row.tx_id ?? "0xexampletransaction",
33786
+ trigger: sub.triggers?.[0]?.type ?? "event",
33787
+ event: input2.row
33788
+ } : input2.row;
33777
33789
  const body = JSON.stringify({
33778
- type: `${input2.subscription.subgraphName}.${input2.subscription.tableName}.created`,
33790
+ type,
33779
33791
  timestamp: new Date(nowSeconds * 1000).toISOString(),
33780
- data: input2.row
33792
+ data
33781
33793
  });
33782
33794
  const headers = {
33783
33795
  "content-type": "application/json",
@@ -33797,6 +33809,13 @@ function buildSubscriptionTestFixture(input2) {
33797
33809
  return { body, headers, curl };
33798
33810
  }
33799
33811
  async function representativeRow(client, sub, subgraph) {
33812
+ if (sub.kind === "chain" || !sub.subgraphName || !sub.tableName) {
33813
+ return {
33814
+ tx_id: "0xexampletransaction",
33815
+ contract_id: "SP000000000000000000002Q6VF78.example",
33816
+ ...sub.triggers?.[0]?.type === "contract_call" ? { function_name: "example-fn" } : {}
33817
+ };
33818
+ }
33800
33819
  try {
33801
33820
  const rows = await client.subgraphs.queryTable(sub.subgraphName, sub.tableName, {
33802
33821
  sort: "_block_height",
@@ -33911,7 +33930,7 @@ Examples:
33911
33930
  const client = await getSubscriptionClient();
33912
33931
  const patch = buildUpdatePatch(options);
33913
33932
  const { id, detail } = await resolveSubscriptionRef(client, idOrName);
33914
- if (patch.filter !== undefined) {
33933
+ if (patch.filter !== undefined && detail.subgraphName && detail.tableName) {
33915
33934
  await validateSubscriptionTargetFromApi(client, {
33916
33935
  subgraphName: detail.subgraphName,
33917
33936
  tableName: detail.tableName,
@@ -34068,7 +34087,7 @@ Examples:
34068
34087
  const [deliveries, dead, subgraph] = await Promise.allSettled([
34069
34088
  client.subscriptions.recentDeliveries(id),
34070
34089
  client.subscriptions.dead(id),
34071
- client.subgraphs.get(detail.subgraphName)
34090
+ detail.subgraphName ? client.subgraphs.get(detail.subgraphName) : Promise.resolve(null)
34072
34091
  ]);
34073
34092
  const report = buildDoctorReport({
34074
34093
  subscription: detail,
@@ -34089,7 +34108,7 @@ Examples:
34089
34108
  const signingSecret = resolveSigningSecret(options);
34090
34109
  const client = await getSubscriptionClient();
34091
34110
  const { detail } = await resolveSubscriptionRef(client, idOrName);
34092
- const subgraph = await client.subgraphs.get(detail.subgraphName).catch(() => null);
34111
+ const subgraph = detail.subgraphName ? await client.subgraphs.get(detail.subgraphName).catch(() => null) : null;
34093
34112
  const row = await representativeRow(client, detail, subgraph);
34094
34113
  const fixture = buildSubscriptionTestFixture({
34095
34114
  subscription: detail,
@@ -38206,5 +38225,5 @@ program.commandsGroup("Account:");
38206
38225
  registerAccountCommand(program);
38207
38226
  program.parse();
38208
38227
 
38209
- //# debugId=7804650EDA8E817964756E2164756E21
38228
+ //# debugId=1CE2C8D6E9B70EC764756E2164756E21
38210
38229
  //# sourceMappingURL=cli.js.map