@secondlayer/stacks 2.5.2 → 2.7.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.
Files changed (56) hide show
  1. package/README.md +65 -0
  2. package/dist/shared/{stacks-jevhg39n.cjs → stacks-7nf5h3qe.cjs} +16 -12
  3. package/dist/shared/{stacks-jevhg39n.cjs.map → stacks-7nf5h3qe.cjs.map} +4 -4
  4. package/dist/shared/{stacks-5th5dffx.js → stacks-a48qj7ss.js} +20 -16
  5. package/dist/shared/{stacks-5th5dffx.js.map → stacks-a48qj7ss.js.map} +4 -4
  6. package/dist/shared/{stacks-7wfdkhj6.cjs → stacks-e7pmsrbs.cjs} +9 -7
  7. package/dist/shared/{stacks-7wfdkhj6.cjs.map → stacks-e7pmsrbs.cjs.map} +3 -3
  8. package/dist/shared/{stacks-7wqprfrm.cjs → stacks-hxm7r5ay.cjs} +3 -3
  9. package/dist/shared/{stacks-7wqprfrm.cjs.map → stacks-hxm7r5ay.cjs.map} +3 -3
  10. package/dist/shared/{stacks-hyz7zgdk.js → stacks-k96f5g1a.js} +2 -2
  11. package/dist/shared/stacks-r3mqgw2d.js +204 -0
  12. package/dist/shared/stacks-r3mqgw2d.js.map +15 -0
  13. package/dist/shared/{stacks-4z1jhw6y.js → stacks-s6v8k4j5.js} +6 -6
  14. package/dist/shared/{stacks-4z1jhw6y.js.map → stacks-s6v8k4j5.js.map} +3 -3
  15. package/dist/shared/{stacks-yq5a5cda.js → stacks-txh6dadn.js} +12 -10
  16. package/dist/shared/{stacks-yq5a5cda.js.map → stacks-txh6dadn.js.map} +3 -3
  17. package/dist/shared/stacks-wb06pevp.cjs +190 -0
  18. package/dist/shared/stacks-wb06pevp.cjs.map +15 -0
  19. package/dist/src/actions/index.d.cts +138 -120
  20. package/dist/src/actions/index.d.ts +138 -120
  21. package/dist/src/actions/index.js +5 -5
  22. package/dist/src/bns/index.d.cts +18 -0
  23. package/dist/src/bns/index.d.ts +18 -0
  24. package/dist/src/bns/index.js +3 -3
  25. package/dist/src/index.cjs +180 -5
  26. package/dist/src/index.cjs.map +7 -5
  27. package/dist/src/index.d.cts +377 -101
  28. package/dist/src/index.d.ts +377 -101
  29. package/dist/src/index.js +193 -10
  30. package/dist/src/index.js.map +7 -5
  31. package/dist/src/pox/index.d.cts +18 -0
  32. package/dist/src/pox/index.d.ts +18 -0
  33. package/dist/src/pox/index.js +3 -3
  34. package/dist/src/sbtc/index.d.cts +18 -0
  35. package/dist/src/sbtc/index.d.ts +18 -0
  36. package/dist/src/sbtc/index.js +3 -3
  37. package/dist/src/stackingdao/index.d.cts +18 -0
  38. package/dist/src/stackingdao/index.d.ts +18 -0
  39. package/dist/src/stackingdao/index.js +3 -3
  40. package/dist/src/subscriptions/index.d.cts +18 -0
  41. package/dist/src/subscriptions/index.d.ts +18 -0
  42. package/dist/src/tools/index.cjs +44 -14
  43. package/dist/src/tools/index.cjs.map +7 -6
  44. package/dist/src/tools/index.d.cts +18 -0
  45. package/dist/src/tools/index.d.ts +18 -0
  46. package/dist/src/tools/index.js +44 -14
  47. package/dist/src/tools/index.js.map +7 -6
  48. package/dist/src/x402/index.d.cts +18 -0
  49. package/dist/src/x402/index.d.ts +18 -0
  50. package/dist/src/x402/index.js +2 -2
  51. package/package.json +1 -1
  52. package/dist/shared/stacks-qk8pdyjy.cjs +0 -76
  53. package/dist/shared/stacks-qk8pdyjy.cjs.map +0 -14
  54. package/dist/shared/stacks-y8e3gx6w.js +0 -90
  55. package/dist/shared/stacks-y8e3gx6w.js.map +0 -14
  56. /package/dist/shared/{stacks-hyz7zgdk.js.map → stacks-k96f5g1a.js.map} +0 -0
@@ -27,106 +27,6 @@ type ProviderAccount = {
27
27
  publicKey: string
28
28
  provider: StacksProvider
29
29
  };
30
- /** Full chain descriptor used by clients and transports for network-aware operations. */
31
- type StacksChain = {
32
- /** Chain ID (e.g. 0x00000001 for mainnet) */
33
- id: number
34
- /** Human-readable name */
35
- name: string
36
- /** Network type */
37
- network: "mainnet" | "testnet"
38
- /** Transaction version byte for serialization */
39
- transactionVersion: number
40
- /** Peer network ID for P2P broadcasting */
41
- peerNetworkId: number
42
- /** Address version bytes */
43
- addressVersion: {
44
- singleSig: number
45
- multiSig: number
46
- }
47
- /** Magic bytes for network identification */
48
- magicBytes: string
49
- /** Boot address (system contracts deployer) */
50
- bootAddress: string
51
- /** Native currency info */
52
- nativeCurrency: {
53
- name: string
54
- symbol: string
55
- decimals: number
56
- }
57
- /** Default RPC URLs */
58
- rpcUrls: {
59
- default: {
60
- http: string[]
61
- ws?: string[]
62
- }
63
- }
64
- /** Block explorer URLs */
65
- blockExplorers?: {
66
- default: {
67
- name: string
68
- url: string
69
- }
70
- }
71
- };
72
- /** Function that sends an HTTP request to a Stacks node API path. */
73
- type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
74
- /** Options for a transport-level HTTP request. */
75
- type RequestOptions = {
76
- method?: "GET" | "POST" | "PUT" | "DELETE"
77
- body?: unknown
78
- headers?: Record<string, string>
79
- };
80
- /** Shared configuration for all transport types. */
81
- type TransportConfig = {
82
- url?: string
83
- timeout?: number
84
- retryCount?: number
85
- retryDelay?: number
86
- fetchOptions?: RequestInit
87
- apiKey?: string
88
- };
89
- /** A resolved transport instance with a bound request function. */
90
- type Transport = {
91
- type: string
92
- request: RequestFn
93
- config: TransportConfig
94
- destroy?: () => void
95
- };
96
- /** Factory that creates a {@link Transport} given an optional chain context. */
97
- type TransportFactory = (params?: {
98
- chain?: StacksChain
99
- }) => Transport;
100
- /** Union of all supported account types (local key, custom signer, or browser provider). */
101
- type Account = LocalAccount | CustomAccount | ProviderAccount;
102
- /**
103
- * Core client instance that holds chain context, transport, and extensible actions.
104
- * Created via {@link createClient}, {@link createPublicClient}, or {@link createWalletClient}.
105
- */
106
- type Client<TExtended extends Record<string, unknown> = Record<string, unknown>> = {
107
- chain?: StacksChain
108
- account?: Account
109
- transport: Transport
110
- request: RequestFn
111
- extend: <const TNew extends Record<string, unknown>>(fn: (client: Client<TExtended>) => TNew) => Client<TExtended & TNew> & TNew
112
- } & TExtended;
113
- /** Configuration for creating a base {@link Client}. */
114
- type ClientConfig = {
115
- chain?: StacksChain
116
- transport: TransportFactory
117
- account?: Account
118
- };
119
- /** A client pre-extended with read-only {@link PublicActions}. */
120
- type PublicClient<TExtended extends Record<string, unknown> = Record<string, unknown>> = Client<TExtended>;
121
- /** A client pre-extended with {@link WalletActions} and a required account. */
122
- type WalletClient<TExtended extends Record<string, unknown> = Record<string, unknown>> = Client<TExtended> & {
123
- account: Account
124
- };
125
- /**
126
- * Create a base client with transport and optional chain/account.
127
- * Use `.extend()` to compose action decorators (public, wallet, multisig).
128
- */
129
- declare function createClient<TExtended extends Record<string, unknown> = Record<string, unknown>>(config: ClientConfig): Client<TExtended>;
130
30
  type IntCV = {
131
31
  readonly type: "int"
132
32
  readonly value: bigint
@@ -377,6 +277,258 @@ type AssetInfoWire = {
377
277
  contractName: string
378
278
  assetName: string
379
279
  };
280
+ /**
281
+ * Provides the confirmed on-chain nonce floor for an address.
282
+ *
283
+ * The default {@link jsonRpcSource} reads the configured node's `/v2/accounts`
284
+ * endpoint — node-agnostic, no Hiro dependency. Other sources (mempool-aware,
285
+ * first-party Index) can be swapped in without touching the manager.
286
+ */
287
+ type NonceManagerSource = {
288
+ get(params: {
289
+ client: Client
290
+ address: string
291
+ }): Promise<bigint>
292
+ };
293
+ /**
294
+ * Holds per-address allocation state and hands out the next nonce.
295
+ *
296
+ * `reserve` MUST be atomic per `key`: two concurrent reservations for the same
297
+ * key must never return the same value. The in-memory {@link memoryStore}
298
+ * serializes with a per-key promise chain; a persisted store (Redis `INCR`,
299
+ * Postgres `SELECT ... FOR UPDATE`) becomes the cross-process lock for the
300
+ * multi-builder / smart-wallet-as-a-service case.
301
+ */
302
+ type NonceStore = {
303
+ /**
304
+ * Reserve the next nonce for `key`. `getFloor` reads the confirmed on-chain
305
+ * nonce; it is only invoked when the store has no tracked value (cold start
306
+ * or after {@link NonceStore.reset}).
307
+ */
308
+ reserve(key: string, getFloor: () => Promise<bigint>): Promise<bigint>
309
+ /** Forget tracked state for `key` so the next reserve re-syncs from the floor. */
310
+ reset(key: string): void | Promise<void>
311
+ /**
312
+ * Return the next nonce that {@link NonceStore.reserve} would hand out for
313
+ * `key` WITHOUT consuming it, or `undefined` if `key` is untracked. Used by
314
+ * {@link reconcileNonce} to detect drift. Optional — stores that omit it
315
+ * simply opt out of reconciliation.
316
+ */
317
+ peek?(key: string): Promise<bigint | undefined> | bigint | undefined
318
+ };
319
+ /** Allocates mempool-safe sequential nonces across rapid broadcasts from one account. */
320
+ type NonceManager = {
321
+ consume(params: {
322
+ client: Client
323
+ address: string
324
+ }): Promise<bigint>
325
+ reset(params: {
326
+ client: Client
327
+ address: string
328
+ }): void | Promise<void>
329
+ /** Next nonce that {@link NonceManager.consume} would return without consuming it, or `undefined` if untracked. */
330
+ peek(params: {
331
+ client: Client
332
+ address: string
333
+ }): Promise<bigint | undefined>
334
+ };
335
+ type CreateNonceManagerParams = {
336
+ source?: NonceManagerSource
337
+ store?: NonceStore
338
+ };
339
+ /** Confirmed-nonce source backed by the configured node's `/v2/accounts` RPC (no Hiro dependency). */
340
+ declare function jsonRpcSource(): NonceManagerSource;
341
+ /**
342
+ * In-memory, single-process store. Tracks the next nonce per key and serializes
343
+ * concurrent reservations with a per-key promise chain.
344
+ *
345
+ * Correct only within one process — swap in a persisted store for multi-process
346
+ * deployments that share a signing key.
347
+ */
348
+ declare function memoryStore(): NonceStore;
349
+ /**
350
+ * Create a nonce manager that floors on a confirmed-nonce {@link NonceManagerSource}
351
+ * and increments a {@link NonceStore} on every {@link NonceManager.consume}.
352
+ *
353
+ * Defaults to {@link jsonRpcSource} + {@link memoryStore} — node-agnostic,
354
+ * single-process, zero external dependencies.
355
+ */
356
+ declare function createNonceManager(params?: CreateNonceManagerParams): NonceManager;
357
+ /** Resolve the next nonce via the client's nonce manager, falling back to a confirmed read. */
358
+ declare function resolveNonce(client: Client, address: string): Promise<bigint>;
359
+ type ReconcileNonceParams = {
360
+ client: Client
361
+ address: string
362
+ /** Authoritative (ideally mempool-aware) source to reconcile against. */
363
+ source: NonceManagerSource
364
+ /**
365
+ * Allow resetting DOWNWARD when the source's next nonce is below what the
366
+ * store tracks — i.e. a previously-allocated tx is no longer pending or
367
+ * confirmed (dropped/GC'd), so its nonce should be reused. Default `true`.
368
+ *
369
+ * Downward resets rely on `source` being current: with a go-forward mempool
370
+ * source that lags broadcast, run reconciliation on an interval comfortably
371
+ * longer than mempool propagation so a still-missing tx is genuinely dropped.
372
+ * Set `false` for upward-only reconciliation (always safe).
373
+ */
374
+ downward?: boolean
375
+ };
376
+ type ReconcileNonceResult = {
377
+ /** Whether the manager was reset (drift detected). */
378
+ reset: boolean
379
+ /** Authoritative next nonce from `source`. */
380
+ authoritative: bigint
381
+ /** Next nonce the store tracked, or `undefined` if untracked. */
382
+ tracked: bigint | undefined
383
+ };
384
+ /**
385
+ * Reconcile a tracked nonce against an authoritative source, healing silent
386
+ * drift that produces no broadcast error (a dropped/GC'd mempool tx leaving the
387
+ * counter overshot, or the chain advancing past the local view).
388
+ *
389
+ * When the source's next nonce differs from the tracked value, the manager is
390
+ * {@link NonceManager.reset}; the next `consume` re-seeds from `source`. A no-op
391
+ * if the store is untracked or does not implement `peek`.
392
+ */
393
+ declare function reconcileNonce(manager: NonceManager, params: ReconcileNonceParams): Promise<ReconcileNonceResult>;
394
+ type StartNonceReconcilerParams = {
395
+ client: Client
396
+ addresses: string[]
397
+ source: NonceManagerSource
398
+ /** Reconcile interval in ms. Default 60_000. Keep well above mempool propagation. */
399
+ intervalMs?: number
400
+ downward?: boolean
401
+ /** Per-address callback after each reconcile (observability). */
402
+ onReconcile?: (address: string, result: ReconcileNonceResult) => void
403
+ /** Per-address error callback; reconciliation continues on the next tick. */
404
+ onError?: (address: string, error: unknown) => void
405
+ };
406
+ /**
407
+ * Run {@link reconcileNonce} on a timer for a set of addresses.
408
+ *
409
+ * SINGLE-WRITER: run this in exactly ONE process. With a shared persisted store,
410
+ * a reconciler resetting the counter while other workers allocate is racy — keep
411
+ * reconciliation on one designated process and let the others only allocate.
412
+ *
413
+ * Returns a handle; call `stop()` to clear the timer.
414
+ */
415
+ declare function startNonceReconciler(manager: NonceManager, params: StartNonceReconcilerParams): {
416
+ stop: () => void
417
+ };
418
+ /** True when a broadcast was rejected for a nonce conflict (`ConflictingNonceInMempool`, `BadNonce`). */
419
+ declare function isNonceConflictError(error: unknown): boolean;
420
+ /**
421
+ * Broadcast a signed transaction; on a nonce-conflict rejection, reset the
422
+ * manager so the next build re-syncs to the confirmed floor.
423
+ */
424
+ declare function broadcastWithNonceReset(client: Client, params: {
425
+ transaction: StacksTransaction
426
+ address: string
427
+ }): Promise<string>;
428
+ /** Full chain descriptor used by clients and transports for network-aware operations. */
429
+ type StacksChain = {
430
+ /** Chain ID (e.g. 0x00000001 for mainnet) */
431
+ id: number
432
+ /** Human-readable name */
433
+ name: string
434
+ /** Network type */
435
+ network: "mainnet" | "testnet"
436
+ /** Transaction version byte for serialization */
437
+ transactionVersion: number
438
+ /** Peer network ID for P2P broadcasting */
439
+ peerNetworkId: number
440
+ /** Address version bytes */
441
+ addressVersion: {
442
+ singleSig: number
443
+ multiSig: number
444
+ }
445
+ /** Magic bytes for network identification */
446
+ magicBytes: string
447
+ /** Boot address (system contracts deployer) */
448
+ bootAddress: string
449
+ /** Native currency info */
450
+ nativeCurrency: {
451
+ name: string
452
+ symbol: string
453
+ decimals: number
454
+ }
455
+ /** Default RPC URLs */
456
+ rpcUrls: {
457
+ default: {
458
+ http: string[]
459
+ ws?: string[]
460
+ }
461
+ }
462
+ /** Block explorer URLs */
463
+ blockExplorers?: {
464
+ default: {
465
+ name: string
466
+ url: string
467
+ }
468
+ }
469
+ };
470
+ /** Function that sends an HTTP request to a Stacks node API path. */
471
+ type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
472
+ /** Options for a transport-level HTTP request. */
473
+ type RequestOptions = {
474
+ method?: "GET" | "POST" | "PUT" | "DELETE"
475
+ body?: unknown
476
+ headers?: Record<string, string>
477
+ };
478
+ /** Shared configuration for all transport types. */
479
+ type TransportConfig = {
480
+ url?: string
481
+ timeout?: number
482
+ retryCount?: number
483
+ retryDelay?: number
484
+ fetchOptions?: RequestInit
485
+ apiKey?: string
486
+ };
487
+ /** A resolved transport instance with a bound request function. */
488
+ type Transport = {
489
+ type: string
490
+ request: RequestFn
491
+ config: TransportConfig
492
+ destroy?: () => void
493
+ };
494
+ /** Factory that creates a {@link Transport} given an optional chain context. */
495
+ type TransportFactory = (params?: {
496
+ chain?: StacksChain
497
+ }) => Transport;
498
+ /** Union of all supported account types (local key, custom signer, or browser provider). */
499
+ type Account = LocalAccount | CustomAccount | ProviderAccount;
500
+ /**
501
+ * Core client instance that holds chain context, transport, and extensible actions.
502
+ * Created via {@link createClient}, {@link createPublicClient}, or {@link createWalletClient}.
503
+ */
504
+ type Client<TExtended extends Record<string, unknown> = Record<string, unknown>> = {
505
+ chain?: StacksChain
506
+ account?: Account
507
+ transport: Transport
508
+ request: RequestFn
509
+ /** Optional nonce manager for mempool-safe sequential nonces across rapid broadcasts. */
510
+ nonceManager?: NonceManager
511
+ extend: <const TNew extends Record<string, unknown>>(fn: (client: Client<TExtended>) => TNew) => Client<TExtended & TNew> & TNew
512
+ } & TExtended;
513
+ /** Configuration for creating a base {@link Client}. */
514
+ type ClientConfig = {
515
+ chain?: StacksChain
516
+ transport: TransportFactory
517
+ account?: Account
518
+ /** Optional nonce manager threaded onto the client (see {@link createNonceManager}). */
519
+ nonceManager?: NonceManager
520
+ };
521
+ /** A client pre-extended with read-only {@link PublicActions}. */
522
+ type PublicClient<TExtended extends Record<string, unknown> = Record<string, unknown>> = Client<TExtended>;
523
+ /** A client pre-extended with {@link WalletActions} and a required account. */
524
+ type WalletClient<TExtended extends Record<string, unknown> = Record<string, unknown>> = Client<TExtended> & {
525
+ account: Account
526
+ };
527
+ /**
528
+ * Create a base client with transport and optional chain/account.
529
+ * Use `.extend()` to compose action decorators (public, wallet, multisig).
530
+ */
531
+ declare function createClient<TExtended extends Record<string, unknown> = Record<string, unknown>>(config: ClientConfig): Client<TExtended>;
380
532
  type EstimateFeeParams = {
381
533
  transaction: StacksTransaction
382
534
  };
@@ -812,6 +964,130 @@ type MultiSigClient = Client<MultiSigActions> & MultiSigActions;
812
964
  */
813
965
  declare function createMultiSigClient(config: MultiSigClientConfig): MultiSigClient;
814
966
  /**
967
+ * Persisted {@link NonceStore} adapters for multi-process / multi-builder
968
+ * deployments (the smart-wallet-as-a-service case).
969
+ *
970
+ * The in-memory {@link memoryStore} is correct only within one process: two
971
+ * workers sharing a signing key both read the same confirmed floor and collide.
972
+ * These adapters move the atomic reserve into a shared datastore — Redis `INCR`
973
+ * inside an `EVAL`, or a single Postgres upsert under a row lock — so the store
974
+ * itself becomes the cross-process lock and the durable source of truth.
975
+ *
976
+ * Both are dependency-injected: pass your own `Bun.redis` / `Bun.sql` client.
977
+ * No global `Bun` reference, so importing this module is runtime-agnostic.
978
+ */
979
+ /** Minimal structural shape of a `Bun.redis` client (the `send` escape hatch). */
980
+ type RedisLike = {
981
+ send(command: string, args: string[]): Promise<unknown>
982
+ };
983
+ type RedisStoreParams = {
984
+ redis: RedisLike
985
+ /** Key prefix for stored nonce counters. Default `"stacks:nonce:"`. */
986
+ prefix?: string
987
+ };
988
+ /**
989
+ * Redis-backed nonce store. The atomic reserve lives in a Lua `EVAL`, so it is
990
+ * safe across processes sharing one Redis. The confirmed floor (`getFloor`) is
991
+ * read only once per key, on cold start.
992
+ */
993
+ declare function redisStore(params: RedisStoreParams): NonceStore;
994
+ /** Minimal structural shape of a `Bun.sql` tagged-template client. */
995
+ type SqlLike = (strings: TemplateStringsArray, ...values: unknown[]) => Promise<Array<Record<string, unknown>>>;
996
+ type PostgresStoreParams = {
997
+ sql: SqlLike
998
+ /**
999
+ * Run `CREATE TABLE IF NOT EXISTS stacks_nonce_state` lazily on first use.
1000
+ * Default `true`. Set `false` if you manage the schema via migrations.
1001
+ */
1002
+ ensureTable?: boolean
1003
+ };
1004
+ /**
1005
+ * Postgres-backed nonce store. Each reserve is a single atomic statement under
1006
+ * a row lock, so concurrent reservers on the same key serialize and never
1007
+ * collide across processes. State is durable — survives restarts.
1008
+ *
1009
+ * Uses a fixed table `stacks_nonce_state (key text primary key, next numeric)`.
1010
+ */
1011
+ declare function postgresStore(params: PostgresStoreParams): NonceStore;
1012
+ /**
1013
+ * Mempool-aware {@link NonceManagerSource}s.
1014
+ *
1015
+ * The default {@link jsonRpcSource} reads only the confirmed nonce, so a tx
1016
+ * sitting in the mempool is invisible — broadcasting many quickly forces manual
1017
+ * tracking. These sources fold pending (mempool) txs into the next-nonce
1018
+ * computation. The gap-filling core is generic; where the pending set comes from
1019
+ * is pluggable, so you are never locked to any one provider:
1020
+ *
1021
+ * - {@link mempoolAwareSource} — bring your own `getPending`.
1022
+ * - {@link indexSource} — prebuilt over Secondlayer's `/v1/index/mempool`.
1023
+ * - {@link hiroNonceSource} — prebuilt over Hiro's `/extended` nonces endpoint.
1024
+ */
1025
+ type FetchImpl = typeof globalThis.fetch;
1026
+ /**
1027
+ * The next free nonce ≥ `confirmed` not already taken by a pending tx.
1028
+ *
1029
+ * Unlike Hiro's `possible_next_nonce` (which is `max(pending) + 1` and strands
1030
+ * higher txs when a lower nonce is missing), this FILLS gaps: it returns the
1031
+ * lowest unused slot, so a dropped-tx hole is reused instead of stranding the
1032
+ * chain.
1033
+ */
1034
+ declare function nextFreeNonce(confirmed: bigint, pending: bigint[]): bigint;
1035
+ type MempoolAwareSourceParams = {
1036
+ /** Pending (mempool) nonces for an address. */
1037
+ getPending: (args: {
1038
+ client: Client
1039
+ address: string
1040
+ }) => Promise<bigint[]>
1041
+ /**
1042
+ * Confirmed-nonce floor. Defaults to the node's `/v2/accounts` read — the
1043
+ * user's own node via the client transport, no provider dependency.
1044
+ */
1045
+ getConfirmed?: (args: {
1046
+ client: Client
1047
+ address: string
1048
+ }) => Promise<bigint>
1049
+ };
1050
+ /**
1051
+ * Build a gap-filling, mempool-aware source from any `getPending`. The confirmed
1052
+ * floor defaults to the node read; if `getPending` throws, the source degrades
1053
+ * to confirmed-only rather than blocking a broadcast.
1054
+ */
1055
+ declare function mempoolAwareSource(params: MempoolAwareSourceParams): NonceManagerSource;
1056
+ type IndexSourceParams = {
1057
+ /** Secondlayer Index base URL. Default `https://api.secondlayer.tools`. */
1058
+ baseUrl?: string
1059
+ /** Optional API key (keyless by default; supply to raise rate limits). */
1060
+ apiKey?: string
1061
+ fetchImpl?: FetchImpl
1062
+ /** Max mempool pages to page through per address. Default 10 (×200 = 2000 txs). */
1063
+ maxPages?: number
1064
+ /** Override the confirmed floor (defaults to the node read). */
1065
+ getConfirmed?: (args: {
1066
+ client: Client
1067
+ address: string
1068
+ }) => Promise<bigint>
1069
+ };
1070
+ /**
1071
+ * Mempool-aware source backed by Secondlayer's `/v1/index/mempool` (our node's
1072
+ * observed mempool). `baseUrl` is configurable — point it at any shape-compatible
1073
+ * endpoint. Note our mempool is a go-forward, single-node observed view (not a
1074
+ * globally-aggregated mempool), so it can lag or miss txs our node never saw.
1075
+ */
1076
+ declare function indexSource(params?: IndexSourceParams): NonceManagerSource;
1077
+ type HiroNonceSourceParams = {
1078
+ /** Hiro API base URL, e.g. `https://api.hiro.so` or `https://api.testnet.hiro.so`. */
1079
+ baseUrl: string
1080
+ apiKey?: string
1081
+ fetchImpl?: FetchImpl
1082
+ };
1083
+ /**
1084
+ * Off-the-shelf, non-Secondlayer mempool-aware source over Hiro's
1085
+ * `/extended/v1/address/{address}/nonces`. Fills the lowest detected gap first,
1086
+ * then falls back to `possible_next_nonce`. Requires a host that serves Hiro's
1087
+ * extended API (a bare stacks-node does not).
1088
+ */
1089
+ declare function hiroNonceSource(params: HiroNonceSourceParams): NonceManagerSource;
1090
+ /**
815
1091
  * Create an HTTP transport for Stacks node RPC calls.
816
1092
  * Falls back to the chain's default RPC URL, then `localhost:3999`.
817
1093
  */
@@ -1069,4 +1345,4 @@ declare class ReadOnlyCallError extends BaseError {
1069
1345
  declare class WebSocketError extends BaseError {
1070
1346
  name: string;
1071
1347
  }
1072
- export { webSocket, walletActions, testnet, publicActions, providerToAccount, parseStx, exports_on as on, multisigActions, mocknet, mainnet, isValidAddress, isAddressEqual, http, getContractAddress, formatStx, fallback, devnet, defineChain, custom, createWalletClient, createPublicClient, createMultiSigClient, createClient, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WebSocketError, WalletClientConfig, WalletClient, WalletActions, TransportFactory, TransportConfig, Transport, TransactionError, TESTNET_ZERO_ADDRESS, SubscriptionFilterSpec, Subscription, StacksProvider, StacksChain, SimulationError, SigningError, SerializationError, RequestOptions, RequestFn, ReadOnlyCallError, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, PoxFunction, MultiSigClientConfig, MultiSigClient, MultiSigActions, MICROSTX_PER_STX, LocalAccount, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, CustomAccount, ContractCallError, ClientConfig, Client, BroadcastError, BnsAction, BaseError, AddressVersion, Account };
1348
+ export { webSocket, walletActions, testnet, startNonceReconciler, resolveNonce, redisStore, reconcileNonce, publicActions, providerToAccount, postgresStore, parseStx, exports_on as on, nextFreeNonce, multisigActions, mocknet, mempoolAwareSource, memoryStore, mainnet, jsonRpcSource, isValidAddress, isNonceConflictError, isAddressEqual, indexSource, http, hiroNonceSource, getContractAddress, formatStx, fallback, devnet, defineChain, custom, createWalletClient, createPublicClient, createNonceManager, createMultiSigClient, createClient, broadcastWithNonceReset, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WebSocketError, WalletClientConfig, WalletClient, WalletActions, TransportFactory, TransportConfig, Transport, TransactionError, TESTNET_ZERO_ADDRESS, SubscriptionFilterSpec, Subscription, StartNonceReconcilerParams, StacksProvider, StacksChain, SqlLike, SimulationError, SigningError, SerializationError, RequestOptions, RequestFn, RedisStoreParams, RedisLike, ReconcileNonceResult, ReconcileNonceParams, ReadOnlyCallError, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, PoxFunction, PostgresStoreParams, NonceStore, NonceManagerSource, NonceManager, MultiSigClientConfig, MultiSigClient, MultiSigActions, MempoolAwareSourceParams, MICROSTX_PER_STX, LocalAccount, IndexSourceParams, HiroNonceSourceParams, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, CustomAccount, CreateNonceManagerParams, ContractCallError, ClientConfig, Client, BroadcastError, BnsAction, BaseError, AddressVersion, Account };