Skip to content

Commit 89158ae

Browse files
authored
Merge pull request #793 from hirosystems/major/stacks.js-update
feat: update stacks.js to next
2 parents ef779b8 + faad57a commit 89158ae

17 files changed

+2548
-832
lines changed

.env-example

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
NEXT_PUBLIC_ALGOLIA_APP_ID=
22
NEXT_PUBLIC_ALGOLIA_API_KEY=
33
NEXT_PUBLIC_ALGOLIA_INDEX=
4-
NEXT_PUBLIC_GTM_ID=
4+
NEXT_PUBLIC_GTM_ID=

app/global.css

+67-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@tailwind components;
33
@tailwind utilities;
44

5-
65
@layer base {
76
:root {
87
--background: 40 14.3% 95.9%;
@@ -74,7 +73,6 @@
7473
.dark .bitcoin {
7574
--primary: 0 0% 100%;
7675
--icon: 0 0% 100%;
77-
7876
}
7977
}
8078

@@ -126,22 +124,42 @@ a[aria-label="Hiro Platform"] {
126124
padding: 0;
127125
}
128126

129-
130127
a[aria-label="Hiro Platform"] div:hover {
131128
background-color: hsla(var(--muted-foreground) / 0.1);
132129
}
133130

134-
h1, h2, h3, h4, h5, h6, code, button, .step {
131+
h1,
132+
h2,
133+
h3,
134+
h4,
135+
h5,
136+
h6,
137+
code,
138+
button,
139+
.step {
135140
font-family: var(--font-aeonikFono), sans-serif;
136141
}
137142

138-
a, h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, option {
143+
a,
144+
h1 a,
145+
h2 a,
146+
h3 a,
147+
h4 a,
148+
h5 a,
149+
h6 a,
150+
option {
139151
font-family: var(--font-aeonikFono), sans-serif;
140152
}
141153

142154
/* TODO: div.prose is for targeting the <Callout> title, need to fix this approach */
143155
/* TODO: div.prose .flex-1 span is for targeting the text inside the <Property> component */
144-
a, p, li, table, input, div.prose .w-0, div.prose .flex-1 span {
156+
a,
157+
p,
158+
li,
159+
table,
160+
input,
161+
div.prose .w-0,
162+
div.prose .flex-1 span {
145163
font-family: var(--font-inter), sans-serif;
146164
}
147165

@@ -179,7 +197,14 @@ p {
179197
line-height: 1.75;
180198
}
181199

182-
body > div.guides > div > article > div.prose > figure:nth-child(37) > div > div {
200+
body
201+
> div.guides
202+
> div
203+
> article
204+
> div.prose
205+
> figure:nth-child(37)
206+
> div
207+
> div {
183208
background: hsl(var(--code));
184209
}
185210

@@ -244,21 +269,32 @@ nav a[href="/guides"] {
244269
text-decoration: underline;
245270
}
246271

247-
[data-radix-scroll-area-viewport] .flex.flex-col.gap-8.pb-10.pt-4.max-md\:px-4.md\:pr-3.md\:pt-10 {
248-
gap: 0;
272+
[data-radix-scroll-area-viewport]
273+
.flex.flex-col.gap-8.pb-10.pt-4.max-md\:px-4.md\:pr-3.md\:pt-10 {
274+
gap: 0;
249275
}
250276

251277
/* Target the header toggle */
252278

253-
body > div > header > nav > div.rounded-md.border.bg-background.p-1.text-sm.text-muted-foreground.max-md\:absolute.max-md\:left-\[50\%\].max-md\:translate-x-\[-50\%\] > a.rounded-md.px-2.py-1.transition-colors.hover\:text-accent-foreground.bg-background.text-accent-foreground {
279+
body
280+
> div
281+
> header
282+
> nav
283+
> div.rounded-md.border.bg-background.p-1.text-sm.text-muted-foreground.max-md\:absolute.max-md\:left-\[50\%\].max-md\:translate-x-\[-50\%\]
284+
> a.rounded-md.px-2.py-1.transition-colors.hover\:text-accent-foreground.bg-background.text-accent-foreground {
254285
background-color: hsl(var(--inverted));
255286
color: hsl(var(--background));
256287
}
257288

258289
/* Target the search component */
259290

260-
body > div > header > nav > div.flex.flex-1.flex-row.items-center.justify-end.md\:gap-2 > button.inline-flex.w-full.max-w-\[240px\].items-center.gap-2.rounded-full.border.bg-secondary\/50.p-1\.5.text-sm.text-muted-foreground.transition-colors.hover\:bg-accent.hover\:text-accent-foreground.max-md\:hidden {
261-
background-color: hsl(var(--background))
291+
body
292+
> div
293+
> header
294+
> nav
295+
> div.flex.flex-1.flex-row.items-center.justify-end.md\:gap-2
296+
> button.inline-flex.w-full.max-w-\[240px\].items-center.gap-2.rounded-full.border.bg-secondary\/50.p-1\.5.text-sm.text-muted-foreground.transition-colors.hover\:bg-accent.hover\:text-accent-foreground.max-md\:hidden {
297+
background-color: hsl(var(--background));
262298
}
263299

264300
p.first\:mt-0 {
@@ -280,7 +316,9 @@ p.first\:mt-0:before {
280316
margin: 0;
281317
}
282318

283-
div.not-prose, div.prose-no-margin, div[role="tablist"] {
319+
div.not-prose,
320+
div.prose-no-margin,
321+
div[role="tablist"] {
284322
background: hsl(var(--background));
285323
}
286324

@@ -295,7 +333,8 @@ form.not-prose.flex.flex-col.gap-4.rounded-lg.border.bg-card.p-4 {
295333
}
296334

297335
/* overrides the background of APIInfo and adjusts sticky header on scroll */
298-
div.prose-no-margin .sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.rounded-lg.border.bg-card.p-3.md\:top-10 {
336+
div.prose-no-margin
337+
.sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.rounded-lg.border.bg-card.p-3.md\:top-10 {
299338
background: hsl(var(--background));
300339
top: 4.5rem;
301340
}
@@ -310,21 +349,24 @@ div.prose-no-margin .sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.roun
310349
}
311350

312351
/* Style for the POST span */
313-
.sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.rounded-lg.border.bg-card.p-3.md\:top-10 > span:first-child {
352+
.sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.rounded-lg.border.bg-card.p-3.md\:top-10
353+
> span:first-child {
314354
position: absolute;
315355
top: 0.75rem;
316356
left: 0.75rem;
317357
}
318358

319359
/* Style for the button */
320-
.sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.rounded-lg.border.bg-card.p-3.md\:top-10 > button {
360+
.sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.rounded-lg.border.bg-card.p-3.md\:top-10
361+
> button {
321362
position: absolute;
322363
top: 0.75rem;
323364
right: 0.75rem;
324365
}
325366

326367
/* Target the inner div containing the endpoint spans */
327-
.sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.rounded-lg.border.bg-card.p-3.md\:top-10 > div {
368+
.sticky.top-24.z-\[2\].flex.flex-row.items-center.gap-2.rounded-lg.border.bg-card.p-3.md\:top-10
369+
> div {
328370
display: flex;
329371
flex-wrap: wrap;
330372
width: 100%;
@@ -340,7 +382,10 @@ div.prose div.footer.not-prose {
340382
font-family: var(--font-aeonikFono), sans-serif !important;
341383
}
342384

343-
.steps > div:nth-child(2) > figure:nth-child(3) > div.flex.flex-row.items-center.gap-2.border-b.bg-muted.px-4.py-1\.5 {
385+
.steps
386+
> div:nth-child(2)
387+
> figure:nth-child(3)
388+
> div.flex.flex-row.items-center.gap-2.border-b.bg-muted.px-4.py-1\.5 {
344389
background: hsl(var(--background)) !important;
345390
}
346391

@@ -355,7 +400,7 @@ div.api-example div.max-xl\:hidden > div:nth-child(1) {
355400
background-color: hsl(var(--inverted));
356401
}
357402

358-
.prose :where(a):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
403+
.prose :where(a):not(:where([class~="not-prose"], [class~="not-prose"] *)) {
359404
text-decoration-color: var(--secondary) !important;
360405
}
361406

@@ -373,8 +418,8 @@ div.api-example div.max-xl\:hidden > div:nth-child(1) {
373418
}
374419

375420
.size-10 {
376-
width: 2.5rem/* 20px */;
377-
height: 2.5rem/* 20px */;
421+
width: 2.5rem /* 20px */;
422+
height: 2.5rem /* 20px */;
378423
}
379424

380425
/* Add a deprecated strike through to sidebar links */
@@ -394,4 +439,4 @@ a[href="/stacks/api/fees/fee-rate"] {
394439

395440
div.divide-y.divide-border.overflow-hidden.rounded-lg.border.bg-card {
396441
background: hsl(var(--background));
397-
}
442+
}

components/card.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type CardProps = {
2121
icon?: ReactNode;
2222
title: string;
2323
description: string;
24+
innerClassName?: string;
2425
} & Omit<LinkProps, "title">;
2526

2627
export function Card({
@@ -38,7 +39,12 @@ export function Card({
3839
props.className
3940
)}
4041
>
41-
<div className="group relative z-10 bg-card p-4 rounded-md hover:bg-accent">
42+
<div
43+
className={cn(
44+
"group relative z-10 bg-card p-4 rounded-[7px] hover:bg-accent",
45+
props.innerClassName
46+
)}
47+
>
4248
{icon ? (
4349
<div className="mb-2 w-fit rounded-md border group-hover:bg-border p-2 text-muted-foreground [&_svg]:size-4">
4450
{icon}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Accounts and addresses
2+
title: Accounts & Addresses
33
description: Learn how to get an address from an account.
44
---
55

@@ -11,46 +11,52 @@ Mainnet: `SP3FGQ8Z7JY9BWYZ5WM53E0M9NK7WHJF0691NZ159`
1111

1212
Testnet: `ST2F4BK4GZH6YFBNHYDDGN4T1RKBA7DA1BJZPJEJJ`
1313

14-
## Get an address
15-
16-
<Tabs items={['Using Connect', 'Using a mnemonic']}>
17-
<Tab value="Using Connect">
18-
```ts
19-
// [!code word:user.profile.stxAddress.mainnet]
20-
import { showConnect } from '@stacks/connect';
21-
22-
showConnect({
23-
appDetails,
24-
userSession,
25-
onFinish: () => {
26-
const user = userSession.loadUserData();
27-
const address = user.profile.stxAddress.mainnet;
28-
29-
console.log(address); // SP1MXSZF4NFC8JQ1TTYGEC2WADMC7Y3GHVZYRX6RF
30-
},
31-
});
32-
```
33-
</Tab>
34-
<Tab value="Using a mnemonic">
35-
```ts
36-
// [!code word:getStxAddress]
37-
import { TransactionVersion } from "@stacks/transactions";
38-
import { generateSecretKey, generateWallet, getStxAddress } from "@stacks/wallet-sdk";
39-
40-
const mnemonic = generateSecretKey();
41-
42-
const wallet = await generateWallet({
43-
secretKey: mnemonic,
44-
password: 'optional-password',
45-
});
46-
47-
const account = wallet.accounts[0];
48-
const mainnetAddress = getStxAddress({
49-
account,
50-
transactionVersion: TransactionVersion.Mainnet
51-
});
52-
53-
console.log(mainnetAddress); // SP1MXSZF4NFC8JQ1TTYGEC2WADMC7Y3GHVZYRX6RF
54-
```
55-
</Tab>
56-
</Tabs>
14+
## Getting an address
15+
16+
### Using Stacks Connect
17+
18+
```ts
19+
// [!code word:user.profile.stxAddress.mainnet]
20+
import { showConnect } from '@stacks/connect';
21+
22+
showConnect({
23+
appDetails,
24+
userSession,
25+
onFinish: () => {
26+
const user = userSession.loadUserData();
27+
const address = user.profile.stxAddress.mainnet;
28+
// 'SP1MXSZF4NFC8JQ1TTYGEC2WADMC7Y3GHVZYRX6RF'
29+
},
30+
});
31+
```
32+
33+
### Using a seed phrase / mnemonic / private key
34+
35+
```ts
36+
// [!code word:privateKeyToAddress]
37+
import { randomSeedPhrase, generateWallet, privateKeyToAddress } from "@stacks/wallet-sdk";
38+
39+
const seed = randomSeedPhrase();
40+
41+
const wallet = await generateWallet({
42+
secretKey: seed,
43+
password: 'secret',
44+
});
45+
46+
const address = privateKeyToAddress(wallet.accounts[0].stxPrivateKey, 'mainnet');
47+
// 'SP1MXSZF4NFC8JQ1TTYGEC2WADMC7Y3GHVZYRX6RF'
48+
```
49+
50+
### Using a public key
51+
52+
```ts
53+
// [!code word:publicKeyToAddress]
54+
import { publicKeyToAddress } from '@stacks/transactions';
55+
56+
const address = publicKeyToAddress(publicKey, 'mainnet');
57+
// 'SP1MXSZF4NFC8JQ1TTYGEC2WADMC7Y3GHVZYRX6RF'
58+
```
59+
60+
{/* todo: add accounts code sections, once we have better abstractions */}
61+
62+
{/* todo: multisig */}

0 commit comments

Comments
 (0)