@secondlayer/stacks 0.2.2 → 1.0.0-alpha.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.
- package/dist/shared/stacks-02actsrx.cjs.map +2 -2
- package/dist/shared/{stacks-xp9n3r0t.js → stacks-09wa7ewe.js} +108 -108
- package/dist/shared/stacks-09wa7ewe.js.map +15 -0
- package/dist/shared/{stacks-ky14tdf6.cjs → stacks-0nfexv24.cjs} +20 -8
- package/dist/shared/stacks-0nfexv24.cjs.map +14 -0
- package/dist/shared/{stacks-an5k8n4t.cjs → stacks-14pgpkrr.cjs} +82 -73
- package/dist/shared/stacks-14pgpkrr.cjs.map +23 -0
- package/dist/shared/{stacks-v6ja2eh7.cjs → stacks-17sdtaxg.cjs} +106 -102
- package/dist/shared/stacks-17sdtaxg.cjs.map +15 -0
- package/dist/shared/{stacks-96gaxfcf.js → stacks-1s5w4ncf.js} +44 -32
- package/dist/shared/stacks-1s5w4ncf.js.map +17 -0
- package/dist/shared/stacks-24h5k94q.cjs.map +3 -3
- package/dist/shared/{stacks-evnzth1q.cjs → stacks-4vzmhw3q.cjs} +3 -3
- package/dist/shared/stacks-4vzmhw3q.cjs.map +10 -0
- package/dist/shared/{stacks-k9p8m3wf.js → stacks-4x2bcc2k.js} +87 -78
- package/dist/shared/stacks-4x2bcc2k.js.map +23 -0
- package/dist/shared/stacks-5tprhns9.cjs.map +3 -3
- package/dist/shared/stacks-709tra19.js.map +2 -2
- package/dist/shared/{stacks-q79dx28x.js → stacks-70p84bgg.js} +3 -3
- package/dist/shared/stacks-70p84bgg.js.map +10 -0
- package/dist/shared/{stacks-k2p5tv6x.js → stacks-913a2rx7.js} +3 -3
- package/dist/shared/stacks-913a2rx7.js.map +10 -0
- package/dist/shared/{stacks-jrnmh4kc.js → stacks-96d6m1zy.js} +15 -6
- package/dist/shared/stacks-96d6m1zy.js.map +11 -0
- package/dist/shared/stacks-9g0jhab3.cjs.map +2 -2
- package/dist/shared/stacks-dr5en54r.cjs.map +2 -2
- package/dist/shared/stacks-fcaefc5b.cjs.map +2 -2
- package/dist/shared/stacks-gck1sq7h.cjs.map +2 -2
- package/dist/shared/stacks-je937aas.js.map +2 -2
- package/dist/shared/{stacks-k58k970n.js → stacks-kg1npstf.js} +5 -3
- package/dist/shared/stacks-kg1npstf.js.map +10 -0
- package/dist/shared/{stacks-qvg7c24g.cjs → stacks-n98w7g57.cjs} +5 -3
- package/dist/shared/stacks-n98w7g57.cjs.map +10 -0
- package/dist/shared/{stacks-6m1z4j07.js → stacks-nqae5amn.cjs} +74 -160
- package/dist/shared/stacks-nqae5amn.cjs.map +10 -0
- package/dist/shared/stacks-qcae5852.js.map +2 -2
- package/dist/shared/stacks-qt8ehebn.js.map +3 -3
- package/dist/shared/stacks-ra02bpny.cjs.map +3 -3
- package/dist/shared/stacks-rwfgts3s.js.map +2 -2
- package/dist/shared/stacks-s10yb9gz.js.map +2 -2
- package/dist/shared/{stacks-etf219gs.cjs → stacks-s30kkvm8.js} +101 -118
- package/dist/shared/stacks-s30kkvm8.js.map +10 -0
- package/dist/shared/stacks-s7z5q8be.js.map +3 -3
- package/dist/shared/stacks-v9jqcpd4.js.map +2 -2
- package/dist/shared/stacks-vdfag81a.cjs.map +2 -2
- package/dist/shared/{stacks-rg1g0fja.js → stacks-wjem3xw9.js} +21 -9
- package/dist/shared/stacks-wjem3xw9.js.map +14 -0
- package/dist/shared/{stacks-k08tgzyp.cjs → stacks-wyxj879g.cjs} +3 -3
- package/dist/shared/stacks-wyxj879g.cjs.map +13 -0
- package/dist/shared/stacks-y3dh7hv1.js.map +3 -3
- package/dist/shared/{stacks-2ar4prfz.cjs → stacks-y5262j0z.cjs} +14 -5
- package/dist/shared/stacks-y5262j0z.cjs.map +11 -0
- package/dist/shared/stacks-ya3x01yd.cjs.map +2 -2
- package/dist/shared/{stacks-p93g814f.js → stacks-zf7rbpzp.js} +4 -4
- package/dist/shared/stacks-zf7rbpzp.js.map +13 -0
- package/dist/shared/{stacks-61rvzkz1.cjs → stacks-znrb59ce.cjs} +41 -29
- package/dist/shared/stacks-znrb59ce.cjs.map +17 -0
- package/dist/src/accounts/index.cjs +2 -2
- package/dist/src/accounts/index.cjs.map +5 -5
- package/dist/src/accounts/index.js +2 -6
- package/dist/src/accounts/index.js.map +5 -5
- package/dist/src/actions/index.d.cts +29 -29
- package/dist/src/actions/index.d.ts +29 -29
- package/dist/src/actions/index.js +7 -7
- package/dist/src/bns/index.cjs +55 -43
- package/dist/src/bns/index.cjs.map +9 -9
- package/dist/src/bns/index.d.cts +29 -29
- package/dist/src/bns/index.d.ts +29 -29
- package/dist/src/bns/index.js +62 -50
- package/dist/src/bns/index.js.map +9 -9
- package/dist/src/clarity/index.js +4 -4
- package/dist/src/connect/index.cjs +114 -112
- package/dist/src/connect/index.cjs.map +13 -13
- package/dist/src/connect/index.js +114 -112
- package/dist/src/connect/index.js.map +13 -13
- package/dist/src/connect/walletconnect/index.cjs +3 -3
- package/dist/src/connect/walletconnect/index.cjs.map +10 -10
- package/dist/src/connect/walletconnect/index.js +3 -3
- package/dist/src/connect/walletconnect/index.js.map +10 -10
- package/dist/src/index.cjs +108 -2
- package/dist/src/index.cjs.map +19 -15
- package/dist/src/index.d.cts +291 -112
- package/dist/src/index.d.ts +291 -112
- package/dist/src/index.js +122 -9
- package/dist/src/index.js.map +19 -15
- package/dist/src/pox/index.cjs.map +6 -6
- package/dist/src/pox/index.d.cts +29 -29
- package/dist/src/pox/index.d.ts +29 -29
- package/dist/src/pox/index.js +5 -5
- package/dist/src/pox/index.js.map +6 -6
- package/dist/src/stackingdao/index.cjs +31 -6
- package/dist/src/stackingdao/index.cjs.map +6 -6
- package/dist/src/stackingdao/index.d.cts +29 -29
- package/dist/src/stackingdao/index.d.ts +29 -29
- package/dist/src/stackingdao/index.js +37 -12
- package/dist/src/stackingdao/index.js.map +6 -6
- package/dist/src/subscriptions/index.d.cts +29 -29
- package/dist/src/subscriptions/index.d.ts +29 -29
- package/dist/src/tools/btc/index.cjs +130 -0
- package/dist/src/tools/btc/index.cjs.map +10 -0
- package/dist/src/tools/btc/index.d.cts +8 -0
- package/dist/src/tools/btc/index.d.ts +8 -0
- package/dist/src/tools/btc/index.js +89 -0
- package/dist/src/tools/btc/index.js.map +10 -0
- package/dist/src/tools/index.cjs +2470 -0
- package/dist/src/tools/index.cjs.map +61 -0
- package/dist/src/tools/index.d.cts +144 -0
- package/dist/src/tools/index.d.ts +144 -0
- package/dist/src/tools/index.js +2435 -0
- package/dist/src/tools/index.js.map +61 -0
- package/dist/src/transactions/index.js +3 -3
- package/dist/src/triggers/index.cjs +66 -0
- package/dist/src/triggers/index.cjs.map +10 -0
- package/dist/src/triggers/index.d.cts +120 -0
- package/dist/src/triggers/index.d.ts +120 -0
- package/dist/src/triggers/index.js +25 -0
- package/dist/src/triggers/index.js.map +10 -0
- package/dist/src/tx/index.cjs +65 -0
- package/dist/src/tx/index.cjs.map +10 -0
- package/dist/src/tx/index.d.cts +42 -0
- package/dist/src/tx/index.d.ts +42 -0
- package/dist/src/tx/index.js +22 -0
- package/dist/src/tx/index.js.map +10 -0
- package/dist/src/ui/index.cjs +431 -0
- package/dist/src/ui/index.cjs.map +27 -0
- package/dist/src/ui/index.d.cts +107 -0
- package/dist/src/ui/index.d.ts +107 -0
- package/dist/src/ui/index.js +391 -0
- package/dist/src/ui/index.js.map +27 -0
- package/dist/src/ui/schemas.cjs +134 -0
- package/dist/src/ui/schemas.cjs.map +18 -0
- package/dist/src/ui/schemas.d.cts +83 -0
- package/dist/src/ui/schemas.d.ts +83 -0
- package/dist/src/ui/schemas.js +91 -0
- package/dist/src/ui/schemas.js.map +18 -0
- package/dist/src/utils/index.cjs +3 -3
- package/dist/src/utils/index.cjs.map +4 -4
- package/dist/src/utils/index.js +4 -4
- package/dist/src/utils/index.js.map +4 -4
- package/package.json +156 -105
- package/dist/shared/stacks-2ar4prfz.cjs.map +0 -11
- package/dist/shared/stacks-61rvzkz1.cjs.map +0 -17
- package/dist/shared/stacks-6m1z4j07.js.map +0 -10
- package/dist/shared/stacks-96gaxfcf.js.map +0 -17
- package/dist/shared/stacks-an5k8n4t.cjs.map +0 -23
- package/dist/shared/stacks-etf219gs.cjs.map +0 -10
- package/dist/shared/stacks-evnzth1q.cjs.map +0 -10
- package/dist/shared/stacks-jrnmh4kc.js.map +0 -11
- package/dist/shared/stacks-k08tgzyp.cjs.map +0 -13
- package/dist/shared/stacks-k2p5tv6x.js.map +0 -10
- package/dist/shared/stacks-k58k970n.js.map +0 -10
- package/dist/shared/stacks-k9p8m3wf.js.map +0 -23
- package/dist/shared/stacks-ky14tdf6.cjs.map +0 -13
- package/dist/shared/stacks-p93g814f.js.map +0 -13
- package/dist/shared/stacks-q79dx28x.js.map +0 -10
- package/dist/shared/stacks-qvg7c24g.cjs.map +0 -10
- package/dist/shared/stacks-rg1g0fja.js.map +0 -13
- package/dist/shared/stacks-v6ja2eh7.cjs.map +0 -15
- package/dist/shared/stacks-xp9n3r0t.js.map +0 -15
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
/** Account derived from a local private key (mnemonic or raw key). */
|
|
2
|
+
type LocalAccount = {
|
|
3
|
+
type: "local"
|
|
4
|
+
address: string
|
|
5
|
+
/** Compressed public key (hex) */
|
|
6
|
+
publicKey: string
|
|
7
|
+
/** Raw ECDSA sign over a hash */
|
|
8
|
+
sign(hash: Uint8Array): Uint8Array
|
|
9
|
+
/** Sign a structured message (SIP-018) */
|
|
10
|
+
signMessage(message: string | Uint8Array): string
|
|
11
|
+
};
|
|
12
|
+
/** Account with a user-provided signing function (sync or async). */
|
|
13
|
+
type CustomAccount = {
|
|
14
|
+
type: "custom"
|
|
15
|
+
address: string
|
|
16
|
+
publicKey: string
|
|
17
|
+
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
18
|
+
};
|
|
19
|
+
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
20
|
+
type StacksProvider = {
|
|
21
|
+
request(method: string, params?: any): Promise<any>
|
|
22
|
+
};
|
|
23
|
+
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
24
|
+
type ProviderAccount = {
|
|
25
|
+
type: "provider"
|
|
26
|
+
address: string
|
|
27
|
+
publicKey: string
|
|
28
|
+
provider: StacksProvider
|
|
29
|
+
};
|
|
1
30
|
/** Full chain descriptor used by clients and transports for network-aware operations. */
|
|
2
31
|
type StacksChain = {
|
|
3
32
|
/** Chain ID (e.g. 0x00000001 for mainnet) */
|
|
@@ -64,35 +93,6 @@ type Transport = {
|
|
|
64
93
|
config: TransportConfig
|
|
65
94
|
destroy?: () => void
|
|
66
95
|
};
|
|
67
|
-
/** Account derived from a local private key (mnemonic or raw key). */
|
|
68
|
-
type LocalAccount = {
|
|
69
|
-
type: "local"
|
|
70
|
-
address: string
|
|
71
|
-
/** Compressed public key (hex) */
|
|
72
|
-
publicKey: string
|
|
73
|
-
/** Raw ECDSA sign over a hash */
|
|
74
|
-
sign(hash: Uint8Array): Uint8Array
|
|
75
|
-
/** Sign a structured message (SIP-018) */
|
|
76
|
-
signMessage(message: string | Uint8Array): string
|
|
77
|
-
};
|
|
78
|
-
/** Account with a user-provided signing function (sync or async). */
|
|
79
|
-
type CustomAccount = {
|
|
80
|
-
type: "custom"
|
|
81
|
-
address: string
|
|
82
|
-
publicKey: string
|
|
83
|
-
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
84
|
-
};
|
|
85
|
-
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
86
|
-
type StacksProvider = {
|
|
87
|
-
request(method: string, params?: any): Promise<any>
|
|
88
|
-
};
|
|
89
|
-
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
90
|
-
type ProviderAccount = {
|
|
91
|
-
type: "provider"
|
|
92
|
-
address: string
|
|
93
|
-
publicKey: string
|
|
94
|
-
provider: StacksProvider
|
|
95
|
-
};
|
|
96
96
|
/** Union of all supported account types (local key, custom signer, or browser provider). */
|
|
97
97
|
type Account = LocalAccount | CustomAccount | ProviderAccount;
|
|
98
98
|
/**
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SIP010_ABI
|
|
3
|
-
} from "../../shared/stacks-
|
|
3
|
+
} from "../../shared/stacks-kg1npstf.js";
|
|
4
4
|
import {
|
|
5
5
|
getContract
|
|
6
|
-
} from "../../shared/stacks-
|
|
7
|
-
import"../../shared/stacks-
|
|
6
|
+
} from "../../shared/stacks-70p84bgg.js";
|
|
7
|
+
import"../../shared/stacks-1s5w4ncf.js";
|
|
8
8
|
import"../../shared/stacks-709tra19.js";
|
|
9
|
-
import"../../shared/stacks-
|
|
9
|
+
import"../../shared/stacks-zf7rbpzp.js";
|
|
10
10
|
import {
|
|
11
11
|
Pc
|
|
12
12
|
} from "../../shared/stacks-je937aas.js";
|
|
13
|
-
import"../../shared/stacks-
|
|
14
|
-
import"../../shared/stacks-
|
|
13
|
+
import"../../shared/stacks-09wa7ewe.js";
|
|
14
|
+
import"../../shared/stacks-wjem3xw9.js";
|
|
15
15
|
import"../../shared/stacks-v9jqcpd4.js";
|
|
16
16
|
import"../../shared/stacks-rwfgts3s.js";
|
|
17
17
|
import"../../shared/stacks-s10yb9gz.js";
|
|
@@ -165,27 +165,52 @@ function assertMainnet(client) {
|
|
|
165
165
|
function getCoreContract(client) {
|
|
166
166
|
assertMainnet(client);
|
|
167
167
|
const c = STACKINGDAO_CONTRACTS.core;
|
|
168
|
-
return getContract({
|
|
168
|
+
return getContract({
|
|
169
|
+
client,
|
|
170
|
+
address: c.address,
|
|
171
|
+
name: c.name,
|
|
172
|
+
abi: STACKING_DAO_CORE_ABI
|
|
173
|
+
});
|
|
169
174
|
}
|
|
170
175
|
function getStstxToken(client) {
|
|
171
176
|
assertMainnet(client);
|
|
172
177
|
const c = STACKINGDAO_CONTRACTS.ststxToken;
|
|
173
|
-
return getContract({
|
|
178
|
+
return getContract({
|
|
179
|
+
client,
|
|
180
|
+
address: c.address,
|
|
181
|
+
name: c.name,
|
|
182
|
+
abi: SIP010_ABI
|
|
183
|
+
});
|
|
174
184
|
}
|
|
175
185
|
function getDataCoreV1(client) {
|
|
176
186
|
assertMainnet(client);
|
|
177
187
|
const c = STACKINGDAO_CONTRACTS.dataCoreV1;
|
|
178
|
-
return getContract({
|
|
188
|
+
return getContract({
|
|
189
|
+
client,
|
|
190
|
+
address: c.address,
|
|
191
|
+
name: c.name,
|
|
192
|
+
abi: DATA_CORE_V1_ABI
|
|
193
|
+
});
|
|
179
194
|
}
|
|
180
195
|
function getDataCoreV3(client) {
|
|
181
196
|
assertMainnet(client);
|
|
182
197
|
const c = STACKINGDAO_CONTRACTS.dataCore;
|
|
183
|
-
return getContract({
|
|
198
|
+
return getContract({
|
|
199
|
+
client,
|
|
200
|
+
address: c.address,
|
|
201
|
+
name: c.name,
|
|
202
|
+
abi: DATA_CORE_V3_ABI
|
|
203
|
+
});
|
|
184
204
|
}
|
|
185
205
|
function getReserveContract(client) {
|
|
186
206
|
assertMainnet(client);
|
|
187
207
|
const c = STACKINGDAO_CONTRACTS.reserve;
|
|
188
|
-
return getContract({
|
|
208
|
+
return getContract({
|
|
209
|
+
client,
|
|
210
|
+
address: c.address,
|
|
211
|
+
name: c.name,
|
|
212
|
+
abi: RESERVE_V1_ABI
|
|
213
|
+
});
|
|
189
214
|
}
|
|
190
215
|
var traits = {
|
|
191
216
|
reserve: TRAIT_CONTRACTS.reserve,
|
|
@@ -311,5 +336,5 @@ export {
|
|
|
311
336
|
STACKINGDAO_CONTRACTS
|
|
312
337
|
};
|
|
313
338
|
|
|
314
|
-
//# debugId=
|
|
339
|
+
//# debugId=E3380693C4EE3B5764756E2164756E21
|
|
315
340
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/stackingdao/abi.ts", "../src/stackingdao/constants.ts", "../src/stackingdao/actions.ts", "../src/stackingdao/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { AbiContract } from \"../clarity/abi/contract.ts\";\n\nconst withdrawTuple = {\n
|
|
6
|
-
"const DEPLOYER: string = \"SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG\";\n\nexport const STACKINGDAO_CONTRACTS: {\n
|
|
7
|
-
"import
|
|
8
|
-
"import type { Client } from \"../clients/types.ts\";\nimport {\n
|
|
5
|
+
"import type { AbiContract } from \"../clarity/abi/contract.ts\";\n\nconst withdrawTuple = {\n\ttuple: [\n\t\t{ name: \"stx-fee-amount\", type: \"uint128\" },\n\t\t{ name: \"stx-user-amount\", type: \"uint128\" },\n\t],\n} as const;\n\nexport const STACKING_DAO_CORE_ABI = {\n\tfunctions: [\n\t\t// Public — deposit STX, receive stSTX\n\t\t{\n\t\t\tname: \"deposit\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"reserve\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"commission-contract\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"staking-contract\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"direct-helpers\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"stx-amount\", type: \"uint128\" },\n\t\t\t\t{ name: \"referrer\", type: { optional: \"principal\" } },\n\t\t\t\t{ name: \"pool\", type: { optional: \"principal\" } },\n\t\t\t],\n\t\t\toutputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n\t\t},\n\t\t// Public — initiate withdrawal (burn stSTX, get NFT receipt)\n\t\t{\n\t\t\tname: \"init-withdraw\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"reserve\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"direct-helpers\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"ststx-amount\", type: \"uint128\" },\n\t\t\t],\n\t\t\toutputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n\t\t},\n\t\t// Public — finalize withdrawal (burn NFT, receive STX)\n\t\t{\n\t\t\tname: \"withdraw\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"reserve\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"commission-contract\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"staking-contract\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"nft-id\", type: \"uint128\" },\n\t\t\t],\n\t\t\toutputs: { response: { ok: withdrawTuple, error: \"uint128\" } },\n\t\t},\n\t\t// Public — withdraw idle STX (instant, no NFT)\n\t\t{\n\t\t\tname: \"withdraw-idle\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"reserve\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"direct-helpers\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"commission-contract\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"staking-contract\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"ststx-amount\", type: \"uint128\" },\n\t\t\t],\n\t\t\toutputs: { response: { ok: withdrawTuple, error: \"uint128\" } },\n\t\t},\n\t\t// Read-only — fees (direct values, no response wrapper)\n\t\t{\n\t\t\tname: \"get-stack-fee\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-unstack-fee\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-withdraw-idle-fee\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t// Read-only — shutdown state (direct bool, no response wrapper)\n\t\t{\n\t\t\tname: \"get-shutdown-deposits\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"bool\",\n\t\t},\n\t],\n} as const satisfies AbiContract;\n\nexport const DATA_CORE_V1_ABI = {\n\tfunctions: [\n\t\t{\n\t\t\tname: \"get-withdrawals-by-nft\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"nft-id\", type: \"uint128\" }],\n\t\t\toutputs: {\n\t\t\t\ttuple: [\n\t\t\t\t\t{ name: \"ststx-amount\", type: \"uint128\" },\n\t\t\t\t\t{ name: \"stx-amount\", type: \"uint128\" },\n\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t],\n} as const satisfies AbiContract;\n\nexport const DATA_CORE_V3_ABI = {\n\tfunctions: [\n\t\t{\n\t\t\tname: \"get-stx-per-ststx-helper\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"stx-amount\", type: \"uint128\" }],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t],\n} as const satisfies AbiContract;\n\nexport const RESERVE_V1_ABI = {\n\tfunctions: [\n\t\t{\n\t\t\tname: \"get-total-stx\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: { response: { ok: \"uint128\", error: \"none\" } },\n\t\t},\n\t],\n} as const satisfies AbiContract;\n",
|
|
6
|
+
"const DEPLOYER: string = \"SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG\";\n\nexport const STACKINGDAO_CONTRACTS: {\n\treadonly core: { readonly address: string; readonly name: string };\n\treadonly ststxToken: { readonly address: string; readonly name: string };\n\treadonly withdrawNft: { readonly address: string; readonly name: string };\n\treadonly reserve: { readonly address: string; readonly name: string };\n\treadonly dataCore: { readonly address: string; readonly name: string };\n\treadonly dataCoreV1: { readonly address: string; readonly name: string };\n} = {\n\tcore: { address: DEPLOYER, name: \"stacking-dao-core-v6\" },\n\tststxToken: { address: DEPLOYER, name: \"ststx-token\" },\n\twithdrawNft: { address: DEPLOYER, name: \"ststx-withdraw-nft-v2\" },\n\treserve: { address: DEPLOYER, name: \"reserve-v1\" },\n\tdataCore: { address: DEPLOYER, name: \"data-core-v3\" },\n\tdataCoreV1: { address: DEPLOYER, name: \"data-core-v1\" },\n} as const;\n\n/** Trait contracts auto-passed to core functions — users never need these. */\nexport const TRAIT_CONTRACTS: {\n\treadonly reserve: string;\n\treadonly commission: string;\n\treadonly directHelpers: string;\n\treadonly staking: string;\n} = {\n\treserve: `${DEPLOYER}.reserve-v1`,\n\tcommission: `${DEPLOYER}.commission-v2`,\n\tdirectHelpers: `${DEPLOYER}.direct-helpers-v4`,\n\tstaking: `${DEPLOYER}.staking-v0`,\n} as const;\n",
|
|
7
|
+
"import { getContract } from \"../actions/getContract.ts\";\nimport { SIP010_ABI } from \"../clarity/abi/standards.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport { Pc } from \"../postconditions/index.ts\";\nimport {\n\tDATA_CORE_V1_ABI,\n\tDATA_CORE_V3_ABI,\n\tRESERVE_V1_ABI,\n\tSTACKING_DAO_CORE_ABI,\n} from \"./abi.ts\";\nimport { STACKINGDAO_CONTRACTS, TRAIT_CONTRACTS } from \"./constants.ts\";\nimport type {\n\tDepositParams,\n\tExchangeRateInfo,\n\tFeeInfo,\n\tInitWithdrawParams,\n\tWithdrawIdleParams,\n\tWithdrawParams,\n\tWithdrawalInfo,\n} from \"./types.ts\";\n\nfunction assertMainnet(client: Client) {\n\tif (!client.chain) {\n\t\tthrow new Error(\"Client must have a chain configured\");\n\t}\n\tif (client.chain.network !== \"mainnet\") {\n\t\tthrow new Error(\"StackingDAO is only available on mainnet\");\n\t}\n}\n\nfunction getCoreContract(client: Client) {\n\tassertMainnet(client);\n\tconst c = STACKINGDAO_CONTRACTS.core;\n\treturn getContract({\n\t\tclient,\n\t\taddress: c.address,\n\t\tname: c.name,\n\t\tabi: STACKING_DAO_CORE_ABI,\n\t});\n}\n\nfunction getStstxToken(client: Client) {\n\tassertMainnet(client);\n\tconst c = STACKINGDAO_CONTRACTS.ststxToken;\n\treturn getContract({\n\t\tclient,\n\t\taddress: c.address,\n\t\tname: c.name,\n\t\tabi: SIP010_ABI,\n\t});\n}\n\nfunction getDataCoreV1(client: Client) {\n\tassertMainnet(client);\n\tconst c = STACKINGDAO_CONTRACTS.dataCoreV1;\n\treturn getContract({\n\t\tclient,\n\t\taddress: c.address,\n\t\tname: c.name,\n\t\tabi: DATA_CORE_V1_ABI,\n\t});\n}\n\nfunction getDataCoreV3(client: Client) {\n\tassertMainnet(client);\n\tconst c = STACKINGDAO_CONTRACTS.dataCore;\n\treturn getContract({\n\t\tclient,\n\t\taddress: c.address,\n\t\tname: c.name,\n\t\tabi: DATA_CORE_V3_ABI,\n\t});\n}\n\nfunction getReserveContract(client: Client) {\n\tassertMainnet(client);\n\tconst c = STACKINGDAO_CONTRACTS.reserve;\n\treturn getContract({\n\t\tclient,\n\t\taddress: c.address,\n\t\tname: c.name,\n\t\tabi: RESERVE_V1_ABI,\n\t});\n}\n\nconst traits = {\n\treserve: TRAIT_CONTRACTS.reserve,\n\tcommissionContract: TRAIT_CONTRACTS.commission,\n\tstakingContract: TRAIT_CONTRACTS.staking,\n\tdirectHelpers: TRAIT_CONTRACTS.directHelpers,\n};\n\n// ── User Actions ──\n\nexport async function deposit(\n\tclient: Client,\n\tparams: DepositParams,\n): Promise<string> {\n\tconst core = getCoreContract(client);\n\treturn core.call.deposit(\n\t\t{\n\t\t\t...traits,\n\t\t\tstxAmount: params.amount,\n\t\t\treferrer: params.referrer ?? null,\n\t\t\tpool: params.pool ?? null,\n\t\t},\n\t\t{\n\t\t\tpostConditions: [\n\t\t\t\tPc.principal(client.account!.address).willSendEq(params.amount).ustx(),\n\t\t\t],\n\t\t},\n\t);\n}\n\nexport async function initWithdraw(\n\tclient: Client,\n\tparams: InitWithdrawParams,\n): Promise<string> {\n\tconst core = getCoreContract(client);\n\tconst ststx = STACKINGDAO_CONTRACTS.ststxToken;\n\treturn core.call.initWithdraw(\n\t\t{\n\t\t\treserve: traits.reserve,\n\t\t\tdirectHelpers: traits.directHelpers,\n\t\t\tststxAmount: params.ststxAmount,\n\t\t},\n\t\t{\n\t\t\tpostConditions: [\n\t\t\t\tPc.principal(client.account!.address)\n\t\t\t\t\t.willSendEq(params.ststxAmount)\n\t\t\t\t\t.ft(`${ststx.address}.${ststx.name}`, \"ststx\"),\n\t\t\t],\n\t\t},\n\t);\n}\n\nexport async function withdraw(\n\tclient: Client,\n\tparams: WithdrawParams,\n): Promise<string> {\n\tconst core = getCoreContract(client);\n\treturn core.call.withdraw({\n\t\treserve: traits.reserve,\n\t\tcommissionContract: traits.commissionContract,\n\t\tstakingContract: traits.stakingContract,\n\t\tnftId: params.nftId,\n\t});\n}\n\nexport async function withdrawIdle(\n\tclient: Client,\n\tparams: WithdrawIdleParams,\n): Promise<string> {\n\tconst core = getCoreContract(client);\n\tconst ststx = STACKINGDAO_CONTRACTS.ststxToken;\n\treturn core.call.withdrawIdle(\n\t\t{\n\t\t\treserve: traits.reserve,\n\t\t\tdirectHelpers: traits.directHelpers,\n\t\t\tcommissionContract: traits.commissionContract,\n\t\t\tstakingContract: traits.stakingContract,\n\t\t\tststxAmount: params.ststxAmount,\n\t\t},\n\t\t{\n\t\t\tpostConditions: [\n\t\t\t\tPc.principal(client.account!.address)\n\t\t\t\t\t.willSendEq(params.ststxAmount)\n\t\t\t\t\t.ft(`${ststx.address}.${ststx.name}`, \"ststx\"),\n\t\t\t],\n\t\t},\n\t);\n}\n\n// ── Read-only Queries ──\n\nexport async function getStSTXBalance(\n\tclient: Client,\n\taddress: string,\n): Promise<bigint> {\n\tconst token = getStstxToken(client);\n\treturn (await token.read.getBalance({ account: address })) as bigint;\n}\n\nexport async function getExchangeRate(\n\tclient: Client,\n): Promise<ExchangeRateInfo> {\n\tconst reserve = getReserveContract(client);\n\tconst dataV3 = getDataCoreV3(client);\n\n\tconst [totalStx, ststxSupply] = await Promise.all([\n\t\treserve.read.getTotalStx({}) as Promise<bigint>,\n\t\tgetTotalSupply(client),\n\t]);\n\n\tconst stxPerStstx = (await dataV3.read.getStxPerStstxHelper({\n\t\tstxAmount: totalStx,\n\t})) as bigint;\n\n\treturn { stxPerStstx, ststxSupply, totalStx };\n}\n\nexport async function getTotalSupply(client: Client): Promise<bigint> {\n\tconst token = getStstxToken(client);\n\treturn (await token.read.getTotalSupply({})) as bigint;\n}\n\nexport async function getWithdrawalInfo(\n\tclient: Client,\n\tnftId: bigint,\n): Promise<WithdrawalInfo> {\n\tconst dataV1 = getDataCoreV1(client);\n\treturn (await dataV1.read.getWithdrawalsByNft({\n\t\tnftId,\n\t})) as WithdrawalInfo;\n}\n\nexport async function getFees(client: Client): Promise<FeeInfo> {\n\tconst core = getCoreContract(client);\n\tconst [stackFee, unstackFee, withdrawIdleFee] = await Promise.all([\n\t\tcore.read.getStackFee({}) as Promise<bigint>,\n\t\tcore.read.getUnstackFee({}) as Promise<bigint>,\n\t\tcore.read.getWithdrawIdleFee({}) as Promise<bigint>,\n\t]);\n\treturn { stackFee, unstackFee, withdrawIdleFee };\n}\n\nexport async function getReserveBalance(client: Client): Promise<bigint> {\n\tconst reserve = getReserveContract(client);\n\treturn (await reserve.read.getTotalStx({})) as bigint;\n}\n\nexport async function getShutdownDeposits(client: Client): Promise<boolean> {\n\tconst core = getCoreContract(client);\n\treturn (await core.read.getShutdownDeposits({})) as boolean;\n}\n",
|
|
8
|
+
"import type { Client } from \"../clients/types.ts\";\nimport {\n\tdeposit,\n\tgetExchangeRate,\n\tgetFees,\n\tgetReserveBalance,\n\tgetShutdownDeposits,\n\tgetStSTXBalance,\n\tgetTotalSupply,\n\tgetWithdrawalInfo,\n\tinitWithdraw,\n\twithdraw,\n\twithdrawIdle,\n} from \"./actions.ts\";\nimport type {\n\tDepositParams,\n\tExchangeRateInfo,\n\tFeeInfo,\n\tInitWithdrawParams,\n\tWithdrawIdleParams,\n\tWithdrawParams,\n\tWithdrawalInfo,\n} from \"./types.ts\";\n\nexport type {\n\tDepositParams,\n\tInitWithdrawParams,\n\tWithdrawParams,\n\tWithdrawIdleParams,\n\tExchangeRateInfo,\n\tWithdrawalInfo,\n\tFeeInfo,\n};\n/** Actions provided by the StackingDAO extension. */\nexport type StackingDaoActions = {\n\tstackingDao: {\n\t\tdeposit: (params: DepositParams) => Promise<string>;\n\t\tinitWithdraw: (params: InitWithdrawParams) => Promise<string>;\n\t\twithdraw: (params: WithdrawParams) => Promise<string>;\n\t\twithdrawIdle: (params: WithdrawIdleParams) => Promise<string>;\n\t\tgetStSTXBalance: (address: string) => Promise<bigint>;\n\t\tgetExchangeRate: () => Promise<ExchangeRateInfo>;\n\t\tgetTotalSupply: () => Promise<bigint>;\n\t\tgetWithdrawalInfo: (nftId: bigint) => Promise<WithdrawalInfo>;\n\t\tgetFees: () => Promise<FeeInfo>;\n\t\tgetReserveBalance: () => Promise<bigint>;\n\t\tgetShutdownDeposits: () => Promise<boolean>;\n\t};\n};\n\nexport { STACKINGDAO_CONTRACTS, TRAIT_CONTRACTS } from \"./constants.ts\";\n\n/**\n * StackingDAO liquid staking extension.\n * Deposit STX → receive stSTX. Auto-compounding stacking rewards.\n *\n * @example\n * import { createWalletClient, http, mainnet } from \"stacks\";\n * import { stackingDao } from \"stacks/stackingdao\";\n *\n * const client = createWalletClient({ ... }).extend(stackingDao());\n *\n * // Deposit STX for stSTX\n * await client.stackingDao.deposit({ amount: 100_000_000_000n });\n *\n * // Check exchange rate\n * const rate = await client.stackingDao.getExchangeRate();\n */\nexport function stackingDao(): (client: Client) => StackingDaoActions {\n\treturn (client: Client) => ({\n\t\tstackingDao: {\n\t\t\t/** Deposit STX, receive stSTX. */\n\t\t\tdeposit: (params: DepositParams) => deposit(client, params),\n\n\t\t\t/** Initiate withdrawal — burns stSTX, mints NFT receipt. */\n\t\t\tinitWithdraw: (params: InitWithdrawParams) =>\n\t\t\t\tinitWithdraw(client, params),\n\n\t\t\t/** Finalize withdrawal — burns NFT, receive STX. */\n\t\t\twithdraw: (params: WithdrawParams) => withdraw(client, params),\n\n\t\t\t/** Withdraw idle STX instantly (burns stSTX). */\n\t\t\twithdrawIdle: (params: WithdrawIdleParams) =>\n\t\t\t\twithdrawIdle(client, params),\n\n\t\t\t/** Get stSTX balance for an address. */\n\t\t\tgetStSTXBalance: (address: string) => getStSTXBalance(client, address),\n\n\t\t\t/** Get current STX/stSTX exchange rate info. */\n\t\t\tgetExchangeRate: () => getExchangeRate(client),\n\n\t\t\t/** Get total stSTX supply. */\n\t\t\tgetTotalSupply: () => getTotalSupply(client),\n\n\t\t\t/** Get withdrawal NFT info by ID. Returns tuple with amounts and unlock height. */\n\t\t\tgetWithdrawalInfo: (nftId: bigint) => getWithdrawalInfo(client, nftId),\n\n\t\t\t/** Get current fee rates. */\n\t\t\tgetFees: () => getFees(client),\n\n\t\t\t/** Get total STX in reserve. */\n\t\t\tgetReserveBalance: () => getReserveBalance(client),\n\n\t\t\t/** Check if deposits are shut down. */\n\t\t\tgetShutdownDeposits: () => getShutdownDeposits(client),\n\t\t},\n\t});\n}\n"
|
|
9
9
|
],
|
|
10
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAEA,IAAM,gBAAgB;AAAA,
|
|
11
|
-
"debugId": "
|
|
10
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAEA,IAAM,gBAAgB;AAAA,EACrB,OAAO;AAAA,IACN,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,mBAAmB,MAAM,UAAU;AAAA,EAC5C;AACD;AAEO,IAAM,wBAAwB;AAAA,EACpC,WAAW;AAAA,IAEV;AAAA,MACC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,QACL,EAAE,MAAM,WAAW,MAAM,kBAAkB;AAAA,QAC3C,EAAE,MAAM,uBAAuB,MAAM,kBAAkB;AAAA,QACvD,EAAE,MAAM,oBAAoB,MAAM,kBAAkB;AAAA,QACpD,EAAE,MAAM,kBAAkB,MAAM,kBAAkB;AAAA,QAClD,EAAE,MAAM,cAAc,MAAM,UAAU;AAAA,QACtC,EAAE,MAAM,YAAY,MAAM,EAAE,UAAU,YAAY,EAAE;AAAA,QACpD,EAAE,MAAM,QAAQ,MAAM,EAAE,UAAU,YAAY,EAAE;AA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AAM,eAAe,MAAM;AAAA,MAG3C,mBAAmB,CAAC,UAAkB,kBAAkB,QAAQ,KAAK;AAAA,MAGrE,SAAS,MAAM,QAAQ,MAAM;AAAA,MAG7B,mBAAmB,MAAM,kBAAkB,MAAM;AAAA,MAGjD,qBAAqB,MAAM,oBAAoB,MAAM;AAAA,IACtD;AAAA,EACD;AAAA;",
|
|
11
|
+
"debugId": "E3380693C4EE3B5764756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
|
@@ -110,6 +110,35 @@ type NftEventNotification = {
|
|
|
110
110
|
tx_id: string
|
|
111
111
|
block_height: number
|
|
112
112
|
};
|
|
113
|
+
/** Account derived from a local private key (mnemonic or raw key). */
|
|
114
|
+
type LocalAccount = {
|
|
115
|
+
type: "local"
|
|
116
|
+
address: string
|
|
117
|
+
/** Compressed public key (hex) */
|
|
118
|
+
publicKey: string
|
|
119
|
+
/** Raw ECDSA sign over a hash */
|
|
120
|
+
sign(hash: Uint8Array): Uint8Array
|
|
121
|
+
/** Sign a structured message (SIP-018) */
|
|
122
|
+
signMessage(message: string | Uint8Array): string
|
|
123
|
+
};
|
|
124
|
+
/** Account with a user-provided signing function (sync or async). */
|
|
125
|
+
type CustomAccount = {
|
|
126
|
+
type: "custom"
|
|
127
|
+
address: string
|
|
128
|
+
publicKey: string
|
|
129
|
+
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
130
|
+
};
|
|
131
|
+
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
132
|
+
type StacksProvider = {
|
|
133
|
+
request(method: string, params?: any): Promise<any>
|
|
134
|
+
};
|
|
135
|
+
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
136
|
+
type ProviderAccount = {
|
|
137
|
+
type: "provider"
|
|
138
|
+
address: string
|
|
139
|
+
publicKey: string
|
|
140
|
+
provider: StacksProvider
|
|
141
|
+
};
|
|
113
142
|
/** Full chain descriptor used by clients and transports for network-aware operations. */
|
|
114
143
|
type StacksChain = {
|
|
115
144
|
/** Chain ID (e.g. 0x00000001 for mainnet) */
|
|
@@ -176,35 +205,6 @@ type Transport = {
|
|
|
176
205
|
config: TransportConfig
|
|
177
206
|
destroy?: () => void
|
|
178
207
|
};
|
|
179
|
-
/** Account derived from a local private key (mnemonic or raw key). */
|
|
180
|
-
type LocalAccount = {
|
|
181
|
-
type: "local"
|
|
182
|
-
address: string
|
|
183
|
-
/** Compressed public key (hex) */
|
|
184
|
-
publicKey: string
|
|
185
|
-
/** Raw ECDSA sign over a hash */
|
|
186
|
-
sign(hash: Uint8Array): Uint8Array
|
|
187
|
-
/** Sign a structured message (SIP-018) */
|
|
188
|
-
signMessage(message: string | Uint8Array): string
|
|
189
|
-
};
|
|
190
|
-
/** Account with a user-provided signing function (sync or async). */
|
|
191
|
-
type CustomAccount = {
|
|
192
|
-
type: "custom"
|
|
193
|
-
address: string
|
|
194
|
-
publicKey: string
|
|
195
|
-
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
196
|
-
};
|
|
197
|
-
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
198
|
-
type StacksProvider = {
|
|
199
|
-
request(method: string, params?: any): Promise<any>
|
|
200
|
-
};
|
|
201
|
-
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
202
|
-
type ProviderAccount = {
|
|
203
|
-
type: "provider"
|
|
204
|
-
address: string
|
|
205
|
-
publicKey: string
|
|
206
|
-
provider: StacksProvider
|
|
207
|
-
};
|
|
208
208
|
/** Union of all supported account types (local key, custom signer, or browser provider). */
|
|
209
209
|
type Account = LocalAccount | CustomAccount | ProviderAccount;
|
|
210
210
|
/**
|
|
@@ -110,6 +110,35 @@ type NftEventNotification = {
|
|
|
110
110
|
tx_id: string
|
|
111
111
|
block_height: number
|
|
112
112
|
};
|
|
113
|
+
/** Account derived from a local private key (mnemonic or raw key). */
|
|
114
|
+
type LocalAccount = {
|
|
115
|
+
type: "local"
|
|
116
|
+
address: string
|
|
117
|
+
/** Compressed public key (hex) */
|
|
118
|
+
publicKey: string
|
|
119
|
+
/** Raw ECDSA sign over a hash */
|
|
120
|
+
sign(hash: Uint8Array): Uint8Array
|
|
121
|
+
/** Sign a structured message (SIP-018) */
|
|
122
|
+
signMessage(message: string | Uint8Array): string
|
|
123
|
+
};
|
|
124
|
+
/** Account with a user-provided signing function (sync or async). */
|
|
125
|
+
type CustomAccount = {
|
|
126
|
+
type: "custom"
|
|
127
|
+
address: string
|
|
128
|
+
publicKey: string
|
|
129
|
+
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
130
|
+
};
|
|
131
|
+
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
132
|
+
type StacksProvider = {
|
|
133
|
+
request(method: string, params?: any): Promise<any>
|
|
134
|
+
};
|
|
135
|
+
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
136
|
+
type ProviderAccount = {
|
|
137
|
+
type: "provider"
|
|
138
|
+
address: string
|
|
139
|
+
publicKey: string
|
|
140
|
+
provider: StacksProvider
|
|
141
|
+
};
|
|
113
142
|
/** Full chain descriptor used by clients and transports for network-aware operations. */
|
|
114
143
|
type StacksChain = {
|
|
115
144
|
/** Chain ID (e.g. 0x00000001 for mainnet) */
|
|
@@ -176,35 +205,6 @@ type Transport = {
|
|
|
176
205
|
config: TransportConfig
|
|
177
206
|
destroy?: () => void
|
|
178
207
|
};
|
|
179
|
-
/** Account derived from a local private key (mnemonic or raw key). */
|
|
180
|
-
type LocalAccount = {
|
|
181
|
-
type: "local"
|
|
182
|
-
address: string
|
|
183
|
-
/** Compressed public key (hex) */
|
|
184
|
-
publicKey: string
|
|
185
|
-
/** Raw ECDSA sign over a hash */
|
|
186
|
-
sign(hash: Uint8Array): Uint8Array
|
|
187
|
-
/** Sign a structured message (SIP-018) */
|
|
188
|
-
signMessage(message: string | Uint8Array): string
|
|
189
|
-
};
|
|
190
|
-
/** Account with a user-provided signing function (sync or async). */
|
|
191
|
-
type CustomAccount = {
|
|
192
|
-
type: "custom"
|
|
193
|
-
address: string
|
|
194
|
-
publicKey: string
|
|
195
|
-
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
196
|
-
};
|
|
197
|
-
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
198
|
-
type StacksProvider = {
|
|
199
|
-
request(method: string, params?: any): Promise<any>
|
|
200
|
-
};
|
|
201
|
-
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
202
|
-
type ProviderAccount = {
|
|
203
|
-
type: "provider"
|
|
204
|
-
address: string
|
|
205
|
-
publicKey: string
|
|
206
|
-
provider: StacksProvider
|
|
207
|
-
};
|
|
208
208
|
/** Union of all supported account types (local key, custom signer, or browser provider). */
|
|
209
209
|
type Account = LocalAccount | CustomAccount | ProviderAccount;
|
|
210
210
|
/**
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
var import_node_module = require("node:module");
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
function __accessProp(key) {
|
|
7
|
+
return this[key];
|
|
8
|
+
}
|
|
9
|
+
var __toCommonJS = (from) => {
|
|
10
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
11
|
+
if (entry)
|
|
12
|
+
return entry;
|
|
13
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (var key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(entry, key))
|
|
17
|
+
__defProp(entry, key, {
|
|
18
|
+
get: __accessProp.bind(from, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
__moduleCache.set(from, entry);
|
|
23
|
+
return entry;
|
|
24
|
+
};
|
|
25
|
+
var __moduleCache;
|
|
26
|
+
var __returnValue = (v) => v;
|
|
27
|
+
function __exportSetter(name, newValue) {
|
|
28
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
29
|
+
}
|
|
30
|
+
var __export = (target, all) => {
|
|
31
|
+
for (var name in all)
|
|
32
|
+
__defProp(target, name, {
|
|
33
|
+
get: all[name],
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
set: __exportSetter.bind(all, name)
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/tools/btc/index.ts
|
|
41
|
+
var exports_btc = {};
|
|
42
|
+
__export(exports_btc, {
|
|
43
|
+
btcUtxos: () => btcUtxos,
|
|
44
|
+
btcFeeEstimate: () => btcFeeEstimate,
|
|
45
|
+
btcConfirmations: () => btcConfirmations,
|
|
46
|
+
btcBlockHeight: () => btcBlockHeight,
|
|
47
|
+
btcBalance: () => btcBalance
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(exports_btc);
|
|
50
|
+
var import_ai = require("ai");
|
|
51
|
+
var import_zod = require("zod");
|
|
52
|
+
function baseUrl() {
|
|
53
|
+
return (process.env.BTC_MEMPOOL_URL ?? "https://mempool.space").replace(/\/$/, "");
|
|
54
|
+
}
|
|
55
|
+
async function get(path) {
|
|
56
|
+
const res = await fetch(`${baseUrl()}${path}`, {
|
|
57
|
+
headers: { Accept: "application/json" }
|
|
58
|
+
});
|
|
59
|
+
if (!res.ok) {
|
|
60
|
+
throw new Error(`BTC mempool.space ${path} → ${res.status} ${res.statusText}`);
|
|
61
|
+
}
|
|
62
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
63
|
+
if (contentType.includes("application/json"))
|
|
64
|
+
return res.json();
|
|
65
|
+
return res.text();
|
|
66
|
+
}
|
|
67
|
+
var BTC_TXID = import_zod.z.string().regex(/^[0-9a-fA-F]{64}$/, "64-character hex BTC txid");
|
|
68
|
+
var BTC_ADDRESS = import_zod.z.string().describe("Bitcoin address (legacy, segwit, or taproot)");
|
|
69
|
+
var btcConfirmations = import_ai.tool({
|
|
70
|
+
description: "Number of confirmations for a Bitcoin transaction. Returns { confirmations, confirmed }.",
|
|
71
|
+
inputSchema: import_zod.z.object({ txid: BTC_TXID }),
|
|
72
|
+
execute: async ({ txid }) => {
|
|
73
|
+
const tx = await get(`/api/tx/${txid}`);
|
|
74
|
+
if (!tx.status.confirmed || tx.status.block_height == null) {
|
|
75
|
+
return { confirmed: false, confirmations: 0 };
|
|
76
|
+
}
|
|
77
|
+
const tip = await get("/api/blocks/tip/height");
|
|
78
|
+
return {
|
|
79
|
+
confirmed: true,
|
|
80
|
+
confirmations: Math.max(0, tip - tx.status.block_height + 1),
|
|
81
|
+
blockHeight: tx.status.block_height
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
var btcBalance = import_ai.tool({
|
|
86
|
+
description: "Bitcoin balance for an address, in satoshis. Returns { confirmedSat, unconfirmedSat }.",
|
|
87
|
+
inputSchema: import_zod.z.object({ address: BTC_ADDRESS }),
|
|
88
|
+
execute: async ({ address }) => {
|
|
89
|
+
const info = await get(`/api/address/${address}`);
|
|
90
|
+
return {
|
|
91
|
+
confirmedSat: info.chain_stats.funded_txo_sum - info.chain_stats.spent_txo_sum,
|
|
92
|
+
unconfirmedSat: info.mempool_stats.funded_txo_sum - info.mempool_stats.spent_txo_sum
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
var btcUtxos = import_ai.tool({
|
|
97
|
+
description: "List of unspent outputs for a Bitcoin address (truncated to `limit`).",
|
|
98
|
+
inputSchema: import_zod.z.object({
|
|
99
|
+
address: BTC_ADDRESS,
|
|
100
|
+
limit: import_zod.z.number().int().min(1).max(50).default(25)
|
|
101
|
+
}),
|
|
102
|
+
execute: async ({ address, limit }) => {
|
|
103
|
+
const utxos = await get(`/api/address/${address}/utxo`);
|
|
104
|
+
return { utxos: utxos.slice(0, limit) };
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
var btcFeeEstimate = import_ai.tool({
|
|
108
|
+
description: "Current Bitcoin fee estimates in sat/vB across priority tiers (fastest, 30-min, hour, economy).",
|
|
109
|
+
inputSchema: import_zod.z.object({}),
|
|
110
|
+
execute: async () => {
|
|
111
|
+
const fees = await get("/api/v1/fees/recommended");
|
|
112
|
+
return {
|
|
113
|
+
fastestSatVb: fees.fastestFee ?? 0,
|
|
114
|
+
halfHourSatVb: fees.halfHourFee ?? 0,
|
|
115
|
+
hourSatVb: fees.hourFee ?? 0,
|
|
116
|
+
economySatVb: fees.economyFee ?? 0,
|
|
117
|
+
minimumSatVb: fees.minimumFee ?? 0
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var btcBlockHeight = import_ai.tool({
|
|
122
|
+
description: "Current Bitcoin chain tip height.",
|
|
123
|
+
inputSchema: import_zod.z.object({}),
|
|
124
|
+
execute: async () => ({
|
|
125
|
+
height: await get("/api/blocks/tip/height")
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
//# debugId=E9A41C992B04F9FD64756E2164756E21
|
|
130
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/btc/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Bitcoin read tools, callable from a Stacks workflow. Useful for sBTC\n * peg-in/peg-out flows, BTC-collateralized lending, and anywhere a Stacks\n * contract's behaviour depends on BTC state.\n *\n * Backed by mempool.space by default. Override per-tool call is not\n * supported today; swap endpoints by setting `BTC_MEMPOOL_URL` in the\n * workflow runtime env. Reads only — no BTC writes.\n *\n * import { btcConfirmations, btcBalance } from \"@secondlayer/stacks/tools/btc\"\n * await step.generateText(\"research\", { tools: { btcConfirmations, btcBalance }, … })\n */\n\nimport { type Tool, tool } from \"ai\";\nimport { z } from \"zod\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Tool's input-schema generic is too\n// precise for isolated-declarations output — we pass tools through to AI SDK\n// which validates at runtime.\ntype LooseTool = Tool<any, any>;\n\nfunction baseUrl(): string {\n\treturn (process.env.BTC_MEMPOOL_URL ?? \"https://mempool.space\").replace(\n\t\t/\\/$/,\n\t\t\"\",\n\t);\n}\n\nasync function get<T>(path: string): Promise<T> {\n\tconst res = await fetch(`${baseUrl()}${path}`, {\n\t\theaders: { Accept: \"application/json\" },\n\t});\n\tif (!res.ok) {\n\t\tthrow new Error(\n\t\t\t`BTC mempool.space ${path} → ${res.status} ${res.statusText}`,\n\t\t);\n\t}\n\tconst contentType = res.headers.get(\"content-type\") ?? \"\";\n\tif (contentType.includes(\"application/json\")) return res.json() as Promise<T>;\n\treturn res.text() as unknown as Promise<T>;\n}\n\nconst BTC_TXID = z\n\t.string()\n\t.regex(/^[0-9a-fA-F]{64}$/, \"64-character hex BTC txid\");\nconst BTC_ADDRESS = z\n\t.string()\n\t.describe(\"Bitcoin address (legacy, segwit, or taproot)\");\n\nexport const btcConfirmations: LooseTool = tool({\n\tdescription:\n\t\t\"Number of confirmations for a Bitcoin transaction. Returns { confirmations, confirmed }.\",\n\tinputSchema: z.object({ txid: BTC_TXID }),\n\texecute: async ({ txid }) => {\n\t\tconst tx = await get<{\n\t\t\tstatus: { confirmed: boolean; block_height?: number };\n\t\t}>(`/api/tx/${txid}`);\n\t\tif (!tx.status.confirmed || tx.status.block_height == null) {\n\t\t\treturn { confirmed: false, confirmations: 0 };\n\t\t}\n\t\tconst tip = await get<number>(\"/api/blocks/tip/height\");\n\t\treturn {\n\t\t\tconfirmed: true,\n\t\t\tconfirmations: Math.max(0, tip - tx.status.block_height + 1),\n\t\t\tblockHeight: tx.status.block_height,\n\t\t};\n\t},\n});\n\nexport const btcBalance: LooseTool = tool({\n\tdescription:\n\t\t\"Bitcoin balance for an address, in satoshis. Returns { confirmedSat, unconfirmedSat }.\",\n\tinputSchema: z.object({ address: BTC_ADDRESS }),\n\texecute: async ({ address }) => {\n\t\tconst info = await get<{\n\t\t\tchain_stats: { funded_txo_sum: number; spent_txo_sum: number };\n\t\t\tmempool_stats: { funded_txo_sum: number; spent_txo_sum: number };\n\t\t}>(`/api/address/${address}`);\n\t\treturn {\n\t\t\tconfirmedSat:\n\t\t\t\tinfo.chain_stats.funded_txo_sum - info.chain_stats.spent_txo_sum,\n\t\t\tunconfirmedSat:\n\t\t\t\tinfo.mempool_stats.funded_txo_sum - info.mempool_stats.spent_txo_sum,\n\t\t};\n\t},\n});\n\nexport const btcUtxos: LooseTool = tool({\n\tdescription:\n\t\t\"List of unspent outputs for a Bitcoin address (truncated to `limit`).\",\n\tinputSchema: z.object({\n\t\taddress: BTC_ADDRESS,\n\t\tlimit: z.number().int().min(1).max(50).default(25),\n\t}),\n\texecute: async ({ address, limit }) => {\n\t\tconst utxos = await get<\n\t\t\tArray<{\n\t\t\t\ttxid: string;\n\t\t\t\tvout: number;\n\t\t\t\tvalue: number;\n\t\t\t\tstatus: { confirmed: boolean; block_height?: number };\n\t\t\t}>\n\t\t>(`/api/address/${address}/utxo`);\n\t\treturn { utxos: utxos.slice(0, limit) };\n\t},\n});\n\nexport const btcFeeEstimate: LooseTool = tool({\n\tdescription:\n\t\t\"Current Bitcoin fee estimates in sat/vB across priority tiers (fastest, 30-min, hour, economy).\",\n\tinputSchema: z.object({}),\n\texecute: async () => {\n\t\tconst fees = await get<Record<string, number>>(\"/api/v1/fees/recommended\");\n\t\treturn {\n\t\t\tfastestSatVb: fees.fastestFee ?? 0,\n\t\t\thalfHourSatVb: fees.halfHourFee ?? 0,\n\t\t\thourSatVb: fees.hourFee ?? 0,\n\t\t\teconomySatVb: fees.economyFee ?? 0,\n\t\t\tminimumSatVb: fees.minimumFee ?? 0,\n\t\t};\n\t},\n});\n\nexport const btcBlockHeight: LooseTool = tool({\n\tdescription: \"Current Bitcoin chain tip height.\",\n\tinputSchema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AAC,CAAC;AAAA,EACxB,SAAS,aAAa;AAAA,IACrB,QAAQ,MAAM,IAAY,wBAAwB;AAAA,EACnD;AACD,CAAC;",
|
|
8
|
+
"debugId": "E9A41C992B04F9FD64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tool } from "ai";
|
|
2
|
+
type LooseTool = Tool<any, any>;
|
|
3
|
+
declare const btcConfirmations: LooseTool;
|
|
4
|
+
declare const btcBalance: LooseTool;
|
|
5
|
+
declare const btcUtxos: LooseTool;
|
|
6
|
+
declare const btcFeeEstimate: LooseTool;
|
|
7
|
+
declare const btcBlockHeight: LooseTool;
|
|
8
|
+
export { btcUtxos, btcFeeEstimate, btcConfirmations, btcBlockHeight, btcBalance };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tool } from "ai";
|
|
2
|
+
type LooseTool = Tool<any, any>;
|
|
3
|
+
declare const btcConfirmations: LooseTool;
|
|
4
|
+
declare const btcBalance: LooseTool;
|
|
5
|
+
declare const btcUtxos: LooseTool;
|
|
6
|
+
declare const btcFeeEstimate: LooseTool;
|
|
7
|
+
declare const btcBlockHeight: LooseTool;
|
|
8
|
+
export { btcUtxos, btcFeeEstimate, btcConfirmations, btcBlockHeight, btcBalance };
|