Skip to content

Commit

Permalink
docs: update notes to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Oct 22, 2024
1 parent f370d73 commit 4d335a7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion content/docs/stacks/stacks.js/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"guides/broadcast-transactions",
"guides/post-conditions",
"guides/use-with-react-native",
"---Reference (next)---",
"---Reference (latest)---",
"...packages",
"---Reference (6.x.x)---",
"...v6"
Expand Down
4 changes: 2 additions & 2 deletions content/docs/stacks/stacks.js/packages/common.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { InlineCode } from '@/components/inline-code';
import { Callout } from "@/components/callout";

<Callout type="info">
This reference refers to the `next` release of Stacks.js, it's the recommended version to use, but might see some changes in the near future.
This reference refers to the `7.x.x` release of Stacks.jsit's the recommended version to use, but not needed for the Stacks Nakamoto release.
Read the [migration guide](https://github.com/hirosystems/stacks.js/blob/next/.github/MIGRATION.md#stacksjs-5xx--7xx) to learn how to update to the latest version.
</Callout>

Expand All @@ -25,7 +25,7 @@ This includes fetch helpers, middleware, and various other functions.
## Installation

```package-install
@stacks/common@next
@stacks/common@latest
```


Expand Down
4 changes: 2 additions & 2 deletions content/docs/stacks/stacks.js/packages/network.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { InlineCode } from '@/components/inline-code';
import { Callout } from "@/components/callout";

<Callout type="info">
This reference refers to the `next` release of Stacks.js, it's the recommended version to use, but might see some changes in the near future.
This reference refers to the `7.x.x` release of Stacks.jsit's the recommended version to use, but not needed for the Stacks Nakamoto release.
Read the [migration guide](https://github.com/hirosystems/stacks.js/blob/next/.github/MIGRATION.md#stacksjs-5xx--7xx) to learn how to update to the latest version.
</Callout>

Expand All @@ -29,7 +29,7 @@ For example, instead of `STACKS_MAINNET`, simply use the string `"mainnet"` as t
</Callout>

```package-install
@stacks/network@next
@stacks/network@latest
```

## Usage
Expand Down
45 changes: 32 additions & 13 deletions content/docs/stacks/stacks.js/roadmap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ title: Announcing Stacks.js v7
description: Discover the future of Stacks.js.
---

Read about what's coming in the `next` version of Stacks.js.
v7 will be here soon!
This version will bring a lot of improvements and new features, but it also adds some breaking changes.
Read about what's new in the latest version of Stacks.js.
This version comes with a lot of improvements and new features, but it also adds some breaking changes.

<Callout type="Info">
Want to use these latest `next` features? Install the release candidate of the packages:
Want to use these latest features? Install packages using the `latest` tag:

```package-install
@stacks/transactions@next
@stacks/transactions@latest
```
</Callout>

Expand All @@ -29,10 +28,9 @@ Private keys were also included unnecessary `type` properties with raw byte arra

#### Solution

We will be switching to a system where most values will be represented as strings.
We switched to a system where most values will be represented as strings.
This makes them easier to inspect and diff.


Clarity example, [Read more](#clarity-representation)
```ts
// [!code word:OLD]
Expand Down Expand Up @@ -65,12 +63,12 @@ This breaks the signatures of many functions:

For a long time, Stacks.js "network" instances were used for "networking" and "network" definitions.
This caused confusion, as most users use `mainnet` or `testnet` for most of their interactions.
The "networking" (aka fetching) logic is now separated from the network object.

This split should make it more obvious when functions are using network object properties vs when they are doing actual networking.
The "networking" (aka fetching) logic is now more clearly customizable.

From now on "network" objects are static (aka constants) and don't require instantiation.

These changes should make it more obvious when functions are using network object properties vs when they are doing actual networking.

In most cases, developers shouldn't need the `@stacks/network` package anymore.
The `network` parameter can be used with string literals: `'mainnet'`, `'testnet'`, `'devnet'`, `'mocknet'`.

Expand All @@ -92,11 +90,12 @@ makeSTXTokenTransfer({
});
```

#### Stacks Network `client`

Networks don't have a `fetch` function anymore and split the fetching logic into a separate parameter where applicable.
#### Stacks Network `client`

For easing the transition, the functions which depended on a network instance now accept an `client` parameter.
In case a function also takes a `client` parameter, it will be doing actual networking.
This way you can use string literal networks with a custom node.
You can also still use network objects with the `client` parameter as part of the network object.
The `client` parameter can be any object-like structure containing a `baseUrl` and `fetch` property.

- The `baseUrl` property should be a string containing the base URL of the Stacks node you want to use.
Expand All @@ -113,6 +112,26 @@ const transaction = await makeSTXTokenTransfer({
});
```

The `client` property is also part of the network object.
You can still keep ONE single network object for your whole application.

```ts
// [!code word:OLD]
// [!code word:NEW]
// OLD:
import { StacksTestnet } from '@stacks/network';

const network = new StacksTestnet({ url: "https://mynode.com", fetchFn: myFetch });

// NEW:
import { STACKS_TESTNET } from '@stacks/network';

const network = {
...STACKS_TESTNET, // extending a static object
client: { baseUrl: "https://mynode.com", fetch: myFetch }
};
```

### A `To` B Helpers

Where possible, Stacks.js now offers function to translate between different representations and concepts.
Expand Down

0 comments on commit 4d335a7

Please sign in to comment.