@secondlayer/stacks 5.0.1 → 5.1.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.
@@ -0,0 +1,133 @@
1
+ import { Simnet } from "@stacks/clarinet-sdk";
2
+ /** Full chain descriptor used by clients and transports for network-aware operations. */
3
+ type StacksChain = {
4
+ /** Chain ID (e.g. 0x00000001 for mainnet) */
5
+ id: number
6
+ /** Human-readable name */
7
+ name: string
8
+ /** Network type */
9
+ network: "mainnet" | "testnet"
10
+ /** Transaction version byte for serialization */
11
+ transactionVersion: number
12
+ /** Peer network ID for P2P broadcasting */
13
+ peerNetworkId: number
14
+ /** Address version bytes */
15
+ addressVersion: {
16
+ singleSig: number
17
+ multiSig: number
18
+ }
19
+ /** Magic bytes for network identification */
20
+ magicBytes: string
21
+ /** Boot address (system contracts deployer) */
22
+ bootAddress: string
23
+ /** Native currency info */
24
+ nativeCurrency: {
25
+ name: string
26
+ symbol: string
27
+ decimals: number
28
+ }
29
+ /** Default RPC URLs */
30
+ rpcUrls: {
31
+ default: {
32
+ http: string[]
33
+ ws?: string[]
34
+ }
35
+ }
36
+ /** Block explorer URLs */
37
+ blockExplorers?: {
38
+ default: {
39
+ name: string
40
+ url: string
41
+ }
42
+ }
43
+ };
44
+ /** Function that sends an HTTP request to a Stacks node API path. */
45
+ type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
46
+ /** Options for a transport-level HTTP request. */
47
+ type RequestOptions = {
48
+ method?: "GET" | "POST" | "PUT" | "DELETE"
49
+ body?: unknown
50
+ headers?: Record<string, string>
51
+ /**
52
+ * Cancel the request from the caller's side. An aborted signal rejects
53
+ * with the signal's reason immediately and never retries; it is combined
54
+ * with the transport's own per-attempt timeout.
55
+ */
56
+ signal?: AbortSignal
57
+ /**
58
+ * Override the transport's retry budget for this one request. Broadcasts
59
+ * pass `0`: re-sending a transaction the node may already hold trades a
60
+ * transient failure for a confusing nonce conflict.
61
+ */
62
+ retryCount?: number
63
+ };
64
+ /** Shared configuration for all transport types. */
65
+ type TransportConfig = {
66
+ url?: string
67
+ /**
68
+ * Per-attempt deadline in ms covering headers AND body. A stalled body
69
+ * rejects with `TimeoutError` instead of hanging. Default 30_000.
70
+ */
71
+ timeout?: number
72
+ retryCount?: number
73
+ retryDelay?: number
74
+ fetchOptions?: RequestInit
75
+ /** Sent as `x-api-key`. Held in the request closure and stripped from
76
+ * `Transport.config` so it never prints with the client. */
77
+ apiKey?: string
78
+ };
79
+ /** A resolved transport instance with a bound request function. */
80
+ type Transport = {
81
+ type: string
82
+ request: RequestFn
83
+ config: TransportConfig
84
+ destroy?: () => void
85
+ };
86
+ /** Factory that creates a {@link Transport} given an optional chain context. */
87
+ type TransportFactory = (params?: {
88
+ chain?: StacksChain
89
+ }) => Transport;
90
+ /**
91
+ * Map Hiro/stacks-node REST paths onto an in-process Clarinet `Simnet`.
92
+ * `getContract` / public+wallet actions then work unchanged against simnet.
93
+ */
94
+ declare function simnet(session: Simnet): TransportFactory;
95
+ /**
96
+ * Chain descriptor for a Clarinet simnet session. Address versions match
97
+ * Clarinet's testnet-style accounts (`ST…`). Boot contracts (pox-5, …) still
98
+ * live at their mainnet principals inside the VM.
99
+ */
100
+ declare const simnetChain: StacksChain;
101
+ declare class BaseError extends Error {
102
+ private;
103
+ name: string;
104
+ shortMessage: string;
105
+ details?: string;
106
+ constructor(shortMessage: string, options?: {
107
+ cause?: Error
108
+ details?: string
109
+ code?: string
110
+ });
111
+ /**
112
+ * Stable identifier for programmatic handling; survives message
113
+ * rewording and minification. An explicit `code` option wins, else it
114
+ * is derived from `name` (`TimeoutError` gives `TIMEOUT_ERROR`).
115
+ */
116
+ get code(): string;
117
+ set code(value: string);
118
+ toJSON(): {
119
+ name: string
120
+ code: string
121
+ message: string
122
+ shortMessage: string
123
+ details: string | undefined
124
+ cause: string | undefined
125
+ };
126
+ }
127
+ /** The simnet transport does not implement this node/API route. */
128
+ declare class SimnetUnsupportedError extends BaseError {
129
+ name: string;
130
+ path: string;
131
+ constructor(path: string);
132
+ }
133
+ export { simnetChain, simnet, SimnetUnsupportedError };