@secondlayer/subgraphs 4.1.3 → 4.1.5

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.
@@ -53,12 +53,24 @@ interface ChainReadClient {
53
53
  };
54
54
  }
55
55
  /**
56
+ * True for a structural empty mapped type (`{}`) and for codegen's
57
+ * `Record<string, never>`. `keyof Record<string, never>` is `string`, so the
58
+ * first check alone is not enough. Local copy of the `getContract` helper —
59
+ * importing `ContractInstance<C>["read"]` would re-enter the codegen-brand
60
+ * conditional this type exists to avoid.
61
+ */
62
+ type IsEmptyArgs<A> = [keyof A & string] extends [never] ? true : Record<string, never> extends A ? true : false;
63
+ type ChainReadMethod<
64
+ A,
65
+ R
66
+ > = IsEmptyArgs<A> extends true ? (args?: A) => R : (args: A) => R;
67
+ /**
56
68
  * The camelCased read methods of an ABI. Spelled out rather than reused from
57
69
  * `ContractInstance<C>["read"]`: that type is a conditional over the codegen
58
70
  * brand, and evaluating it wherever a subgraph definition is structurally
59
71
  * compared pushes TS past its instantiation depth.
60
72
  */
61
- type ChainReadMethods<C extends AbiContract> = { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>) => Promise<UnwrapResponse<ExtractFunctionOutput<C, N>>> };
73
+ type ChainReadMethods<C extends AbiContract> = { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : ChainReadMethod<ExtractFunctionArgs<C, N>, Promise<UnwrapResponse<ExtractFunctionOutput<C, N>>>> };
62
74
  /**
63
75
  * `ChainReadClient` with the ABI generic erased. Structurally cheap, so the
64
76
  * base `SubgraphContext` can carry it; `TypedSubgraphContext` uses the real
@@ -76,7 +88,7 @@ interface ErasedChainReadClient {
76
88
  * const token = readContractAt(ctx, contractId, SIP010_ABI, {
77
89
  * cache: "contract-constant",
78
90
  * });
79
- * const decimals = await token.read.getDecimals({}); // bigint
91
+ * const decimals = await token.read.getDecimals(); // bigint
80
92
  * ```
81
93
  */
82
94
  declare function readContractAt<const C extends AbiContract>(ctx: {
@@ -1034,8 +1046,10 @@ interface InferredTopicSchema {
1034
1046
  fields: InferredPrintField[];
1035
1047
  }
1036
1048
  /**
1037
- * Kebab-case → camelCase using the exact runner regex, so `camel_name`
1038
- * matches what handlers see on `e.data` (runner.ts camelizeKeys).
1049
+ * Kebab-case → camelCase for print tuple keys. Canonical: the runner uses
1050
+ * this on `event.data`, and `camel_name` in inferred print schema is the
1051
+ * same function. Distinct from ABI `toCamelCase` (`transfer-STX` stays
1052
+ * `transfer-STX` here, becomes `transferSTX` there).
1039
1053
  */
1040
1054
  declare function camelizeDataKey(str: string): string;
1041
1055
  /**