@secondlayer/stacks 5.1.1 → 5.1.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/README.md +16 -333
- package/dist/shared/{stacks-w9t61fra.cjs → stacks-f35mnrmg.cjs} +6 -6
- package/dist/shared/stacks-f35mnrmg.cjs.map +10 -0
- package/dist/shared/{stacks-gyp5ax89.js → stacks-fd4rx56e.js} +6 -6
- package/dist/shared/stacks-fd4rx56e.js.map +10 -0
- package/dist/src/actions/index.d.cts +19 -7
- package/dist/src/actions/index.d.ts +19 -7
- package/dist/src/actions/index.js +1 -1
- package/dist/src/bns/index.js +1 -1
- package/dist/src/filters/index.d.cts +3 -3
- package/dist/src/filters/index.d.ts +3 -3
- package/dist/src/index.d.cts +2 -2
- package/dist/src/index.d.ts +2 -2
- package/dist/src/pox/index.js +1 -1
- package/dist/src/pox5/index.js +1 -1
- package/dist/src/sbtc/index.js +1 -1
- package/dist/src/stackingdao/index.js +1 -1
- package/dist/src/tools/index.cjs +5 -5
- package/dist/src/tools/index.cjs.map +3 -3
- package/dist/src/tools/index.js +5 -5
- package/dist/src/tools/index.js.map +3 -3
- package/package.json +2 -2
- package/dist/shared/stacks-gyp5ax89.js.map +0 -10
- package/dist/shared/stacks-w9t61fra.cjs.map +0 -10
|
@@ -1286,6 +1286,18 @@ type UnwrapResponse<T> = T extends {
|
|
|
1286
1286
|
} ? O : T extends {
|
|
1287
1287
|
err: unknown
|
|
1288
1288
|
} ? never : T;
|
|
1289
|
+
/**
|
|
1290
|
+
* True for a structural empty mapped type (`{}`) and for codegen's
|
|
1291
|
+
* `Record<string, never>`. `keyof Record<string, never>` is `string`, so the
|
|
1292
|
+
* first check alone is not enough.
|
|
1293
|
+
*/
|
|
1294
|
+
type IsEmptyArgs<A> = [keyof A & string] extends [never] ? true : Record<string, never> extends A ? true : false;
|
|
1295
|
+
/** No-arg ABI functions may omit the dummy `{}`. Functions with args stay required. */
|
|
1296
|
+
type ContractMethod<
|
|
1297
|
+
A,
|
|
1298
|
+
R,
|
|
1299
|
+
Extra extends unknown[] = []
|
|
1300
|
+
> = IsEmptyArgs<A> extends true ? (args?: A, ...extra: Extra) => R : (args: A, ...extra: Extra) => R;
|
|
1289
1301
|
type ReadMethodReturn<
|
|
1290
1302
|
C extends AbiContract,
|
|
1291
1303
|
N extends ExtractReadOnlyFunctions<C>
|
|
@@ -1295,11 +1307,11 @@ type ReadMethodReturn<
|
|
|
1295
1307
|
* the generated named aliases — cleaner hovers and error messages. Un-branded
|
|
1296
1308
|
* ABIs fall back to structural inference over the as-const literal.
|
|
1297
1309
|
*/
|
|
1298
|
-
type TypedReadMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "read-only" ? K : never] :
|
|
1299
|
-
type TypedCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] :
|
|
1310
|
+
type TypedReadMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "read-only" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<UnwrapResponse<T["functions"][K]["ret"]>>> };
|
|
1311
|
+
type TypedCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<string>, [options?: ContractCallOptions]> };
|
|
1300
1312
|
type TypedMapMethods<T extends ContractTypes> = { [K in keyof NonNullable<T["maps"]>] : (key: NonNullable<T["maps"]>[K]["key"]) => Promise<NonNullable<T["maps"]>[K]["value"] | null> };
|
|
1301
|
-
type ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] :
|
|
1302
|
-
type CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] :
|
|
1313
|
+
type ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<ReadMethodReturn<C, N>>> } : TypedReadMethods<AbiTypesOf<C>>;
|
|
1314
|
+
type CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<string>, [options?: ContractCallOptions]> } : TypedCallMethods<AbiTypesOf<C>>;
|
|
1303
1315
|
type MapMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractMapNames<C> as ToCamelCase<N>] : (key: ExtractMapKey<C, N>) => Promise<ExtractMapValue<C, N> | null> } : TypedMapMethods<AbiTypesOf<C>>;
|
|
1304
1316
|
type ContractCallOptions = {
|
|
1305
1317
|
fee?: IntegerType
|
|
@@ -1319,8 +1331,8 @@ type ContractBuildCallOptions = ContractCallOptions & {
|
|
|
1319
1331
|
publicKey?: string
|
|
1320
1332
|
sponsored?: boolean
|
|
1321
1333
|
};
|
|
1322
|
-
type TypedBuildCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] :
|
|
1323
|
-
type BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] :
|
|
1334
|
+
type TypedBuildCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<StacksTransaction>, [options?: ContractBuildCallOptions]> };
|
|
1335
|
+
type BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<StacksTransaction>, [options?: ContractBuildCallOptions]> } : TypedBuildCallMethods<AbiTypesOf<C>>;
|
|
1324
1336
|
type ContractInstance<C extends AbiContract> = {
|
|
1325
1337
|
read: ReadMethods<C>
|
|
1326
1338
|
call: CallMethods<C>
|
|
@@ -1341,7 +1353,7 @@ declare function getContract<const TAbi extends AbiContract>(params: GetContract
|
|
|
1341
1353
|
* it) can reuse the same encoding this module's read methods use, instead of
|
|
1342
1354
|
* maintaining a second one that drifts.
|
|
1343
1355
|
*/
|
|
1344
|
-
declare function buildFunctionArgs(fn: AbiFunction, args
|
|
1356
|
+
declare function buildFunctionArgs(fn: AbiFunction, args?: Record<string, unknown>): ClarityValue[];
|
|
1345
1357
|
/** True when an ABI output is a `(response ok err)` and needs unwrapping. */
|
|
1346
1358
|
declare function isResponseOutput(type: AbiType): boolean;
|
|
1347
1359
|
declare class ContractResponseError extends Error {
|
package/dist/src/bns/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ContractResponseError,
|
|
5
5
|
getContract,
|
|
6
6
|
resolveNetworkContract
|
|
7
|
-
} from "../../shared/stacks-
|
|
7
|
+
} from "../../shared/stacks-fd4rx56e.js";
|
|
8
8
|
import"../../shared/stacks-v03zef3g.js";
|
|
9
9
|
import"../../shared/stacks-qex691bh.js";
|
|
10
10
|
import"../../shared/stacks-x0qqwrev.js";
|
|
@@ -189,7 +189,7 @@ interface StxLockSpec {
|
|
|
189
189
|
minAmount?: bigint;
|
|
190
190
|
}
|
|
191
191
|
/** Scope to contracts conforming to a trait/standard (e.g. "sip-010") instead
|
|
192
|
-
* of a fixed contract. Index + Subgraphs +
|
|
192
|
+
* of a fixed contract. Index + Subgraphs + Webhooks; Streams has no
|
|
193
193
|
* trait resolution — `toStreamsParams()` throws if set. */
|
|
194
194
|
type TraitScope = {
|
|
195
195
|
trait?: string
|
|
@@ -300,7 +300,7 @@ type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
|
300
300
|
type: T
|
|
301
301
|
}>;
|
|
302
302
|
/** The members expressible as subgraph sources (everything but the
|
|
303
|
-
*
|
|
303
|
+
* Webhooks-only sBTC lifecycle types). Instantiating
|
|
304
304
|
* `ChainEventFilter<SubgraphMemberType>` keeps `toSubgraphSource` present:
|
|
305
305
|
* the conditional in `ProjectionsFor` evaluates over this whole union
|
|
306
306
|
* (non-distributive at an instantiated site), and every member qualifies. */
|
|
@@ -310,7 +310,7 @@ type SubgraphMemberType = Exclude<ChainEventFilterType, `sbtc_${string}`>;
|
|
|
310
310
|
type SubgraphSourceSpec = Extract<ChainEventFilterSpec, {
|
|
311
311
|
type: SubgraphMemberType
|
|
312
312
|
}>;
|
|
313
|
-
/** Wire shape of a chain trigger (
|
|
313
|
+
/** Wire shape of a chain trigger (Webhooks), derived per member from
|
|
314
314
|
* the spec: same fields, with `bigint` amounts stringified (uint128 exceeds
|
|
315
315
|
* JS safe integers) and the type-only `abi`/`prints` decorations dropped.
|
|
316
316
|
* Structurally assignable to the SDK's `ChainTrigger` union. */
|
|
@@ -189,7 +189,7 @@ interface StxLockSpec {
|
|
|
189
189
|
minAmount?: bigint;
|
|
190
190
|
}
|
|
191
191
|
/** Scope to contracts conforming to a trait/standard (e.g. "sip-010") instead
|
|
192
|
-
* of a fixed contract. Index + Subgraphs +
|
|
192
|
+
* of a fixed contract. Index + Subgraphs + Webhooks; Streams has no
|
|
193
193
|
* trait resolution — `toStreamsParams()` throws if set. */
|
|
194
194
|
type TraitScope = {
|
|
195
195
|
trait?: string
|
|
@@ -300,7 +300,7 @@ type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
|
300
300
|
type: T
|
|
301
301
|
}>;
|
|
302
302
|
/** The members expressible as subgraph sources (everything but the
|
|
303
|
-
*
|
|
303
|
+
* Webhooks-only sBTC lifecycle types). Instantiating
|
|
304
304
|
* `ChainEventFilter<SubgraphMemberType>` keeps `toSubgraphSource` present:
|
|
305
305
|
* the conditional in `ProjectionsFor` evaluates over this whole union
|
|
306
306
|
* (non-distributive at an instantiated site), and every member qualifies. */
|
|
@@ -310,7 +310,7 @@ type SubgraphMemberType = Exclude<ChainEventFilterType, `sbtc_${string}`>;
|
|
|
310
310
|
type SubgraphSourceSpec = Extract<ChainEventFilterSpec, {
|
|
311
311
|
type: SubgraphMemberType
|
|
312
312
|
}>;
|
|
313
|
-
/** Wire shape of a chain trigger (
|
|
313
|
+
/** Wire shape of a chain trigger (Webhooks), derived per member from
|
|
314
314
|
* the spec: same fields, with `bigint` amounts stringified (uint128 exceeds
|
|
315
315
|
* JS safe integers) and the type-only `abi`/`prints` decorations dropped.
|
|
316
316
|
* Structurally assignable to the SDK's `ChainTrigger` union. */
|
package/dist/src/index.d.cts
CHANGED
|
@@ -187,7 +187,7 @@ interface StxLockSpec {
|
|
|
187
187
|
minAmount?: bigint;
|
|
188
188
|
}
|
|
189
189
|
/** Scope to contracts conforming to a trait/standard (e.g. "sip-010") instead
|
|
190
|
-
* of a fixed contract. Index + Subgraphs +
|
|
190
|
+
* of a fixed contract. Index + Subgraphs + Webhooks; Streams has no
|
|
191
191
|
* trait resolution — `toStreamsParams()` throws if set. */
|
|
192
192
|
type TraitScope = {
|
|
193
193
|
trait?: string
|
|
@@ -297,7 +297,7 @@ type ChainEventFilterSpec = StxTransferSpec | StxMintSpec | StxBurnSpec | StxLoc
|
|
|
297
297
|
type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
298
298
|
type: T
|
|
299
299
|
}>;
|
|
300
|
-
/** Wire shape of a chain trigger (
|
|
300
|
+
/** Wire shape of a chain trigger (Webhooks), derived per member from
|
|
301
301
|
* the spec: same fields, with `bigint` amounts stringified (uint128 exceeds
|
|
302
302
|
* JS safe integers) and the type-only `abi`/`prints` decorations dropped.
|
|
303
303
|
* Structurally assignable to the SDK's `ChainTrigger` union. */
|
package/dist/src/index.d.ts
CHANGED
|
@@ -187,7 +187,7 @@ interface StxLockSpec {
|
|
|
187
187
|
minAmount?: bigint;
|
|
188
188
|
}
|
|
189
189
|
/** Scope to contracts conforming to a trait/standard (e.g. "sip-010") instead
|
|
190
|
-
* of a fixed contract. Index + Subgraphs +
|
|
190
|
+
* of a fixed contract. Index + Subgraphs + Webhooks; Streams has no
|
|
191
191
|
* trait resolution — `toStreamsParams()` throws if set. */
|
|
192
192
|
type TraitScope = {
|
|
193
193
|
trait?: string
|
|
@@ -297,7 +297,7 @@ type ChainEventFilterSpec = StxTransferSpec | StxMintSpec | StxBurnSpec | StxLoc
|
|
|
297
297
|
type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
298
298
|
type: T
|
|
299
299
|
}>;
|
|
300
|
-
/** Wire shape of a chain trigger (
|
|
300
|
+
/** Wire shape of a chain trigger (Webhooks), derived per member from
|
|
301
301
|
* the spec: same fields, with `bigint` amounts stringified (uint128 exceeds
|
|
302
302
|
* JS safe integers) and the type-only `abi`/`prints` decorations dropped.
|
|
303
303
|
* Structurally assignable to the SDK's `ChainTrigger` union. */
|
package/dist/src/pox/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import"../../shared/stacks-z90xdr1x.js";
|
|
|
9
9
|
import {
|
|
10
10
|
getContract,
|
|
11
11
|
resolveNetworkContract
|
|
12
|
-
} from "../../shared/stacks-
|
|
12
|
+
} from "../../shared/stacks-fd4rx56e.js";
|
|
13
13
|
import"../../shared/stacks-v03zef3g.js";
|
|
14
14
|
import"../../shared/stacks-qex691bh.js";
|
|
15
15
|
import"../../shared/stacks-x0qqwrev.js";
|
package/dist/src/pox5/index.js
CHANGED
package/dist/src/sbtc/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
getContract,
|
|
9
9
|
resolveNetworkContract
|
|
10
|
-
} from "../../shared/stacks-
|
|
10
|
+
} from "../../shared/stacks-fd4rx56e.js";
|
|
11
11
|
import"../../shared/stacks-v03zef3g.js";
|
|
12
12
|
import"../../shared/stacks-qex691bh.js";
|
|
13
13
|
import"../../shared/stacks-x0qqwrev.js";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "../../shared/stacks-kg1npstf.js";
|
|
4
4
|
import {
|
|
5
5
|
getContract
|
|
6
|
-
} from "../../shared/stacks-
|
|
6
|
+
} from "../../shared/stacks-fd4rx56e.js";
|
|
7
7
|
import"../../shared/stacks-v03zef3g.js";
|
|
8
8
|
import"../../shared/stacks-qex691bh.js";
|
|
9
9
|
import"../../shared/stacks-x0qqwrev.js";
|
package/dist/src/tools/index.cjs
CHANGED
|
@@ -2563,7 +2563,7 @@ function getContract(params) {
|
|
|
2563
2563
|
const fn = fnByName.get(fnName);
|
|
2564
2564
|
if (!fn || fn.access !== "read-only")
|
|
2565
2565
|
return;
|
|
2566
|
-
return async (args) => {
|
|
2566
|
+
return async (args = {}) => {
|
|
2567
2567
|
const clarityArgs = buildFunctionArgs(fn, args);
|
|
2568
2568
|
const result = await readContract(client, {
|
|
2569
2569
|
contract: contractId,
|
|
@@ -2587,7 +2587,7 @@ function getContract(params) {
|
|
|
2587
2587
|
const fn = fnByName.get(fnName);
|
|
2588
2588
|
if (!fn || fn.access !== "public")
|
|
2589
2589
|
return;
|
|
2590
|
-
return async (args, options) => {
|
|
2590
|
+
return async (args = {}, options) => {
|
|
2591
2591
|
const clarityArgs = buildFunctionArgs(fn, args);
|
|
2592
2592
|
return callContract(client, {
|
|
2593
2593
|
contract: contractId,
|
|
@@ -2604,7 +2604,7 @@ function getContract(params) {
|
|
|
2604
2604
|
const fn = fnByName.get(fnName);
|
|
2605
2605
|
if (!fn || fn.access !== "public")
|
|
2606
2606
|
return;
|
|
2607
|
-
return async (args, options) => {
|
|
2607
|
+
return async (args = {}, options) => {
|
|
2608
2608
|
const publicKey = options?.publicKey ?? client.account?.publicKey;
|
|
2609
2609
|
if (!publicKey) {
|
|
2610
2610
|
throw new Error("buildCall requires a publicKey (pass options.publicKey or configure a client account)");
|
|
@@ -2665,7 +2665,7 @@ function resolveNetworkContract(client, contracts) {
|
|
|
2665
2665
|
}
|
|
2666
2666
|
return contracts[client.chain.network];
|
|
2667
2667
|
}
|
|
2668
|
-
function buildFunctionArgs(fn, args) {
|
|
2668
|
+
function buildFunctionArgs(fn, args = {}) {
|
|
2669
2669
|
return fn.args.map((arg) => {
|
|
2670
2670
|
const camelKey = toCamelCase(arg.name);
|
|
2671
2671
|
const hasOriginal = arg.name in args;
|
|
@@ -3861,5 +3861,5 @@ var getAccountHistory2 = defaultTools.getAccountHistory;
|
|
|
3861
3861
|
var getMempoolStats2 = defaultTools.getMempoolStats;
|
|
3862
3862
|
var getNftHoldings2 = defaultTools.getNftHoldings;
|
|
3863
3863
|
|
|
3864
|
-
//# debugId=
|
|
3864
|
+
//# debugId=DE29EDB00BA8B07A64756E2164756E21
|
|
3865
3865
|
//# sourceMappingURL=index.cjs.map
|