diff --git a/content/docs/stacks/stacks.js/meta.json b/content/docs/stacks/stacks.js/meta.json index 73c828d8..f8a0ea01 100644 --- a/content/docs/stacks/stacks.js/meta.json +++ b/content/docs/stacks/stacks.js/meta.json @@ -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" diff --git a/content/docs/stacks/stacks.js/packages/common.mdx b/content/docs/stacks/stacks.js/packages/common.mdx index 5b309430..e9a5551e 100644 --- a/content/docs/stacks/stacks.js/packages/common.mdx +++ b/content/docs/stacks/stacks.js/packages/common.mdx @@ -15,7 +15,7 @@ import { InlineCode } from '@/components/inline-code'; import { Callout } from "@/components/callout"; -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.js—it'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. @@ -25,7 +25,7 @@ This includes fetch helpers, middleware, and various other functions. ## Installation ```package-install -@stacks/common@next +@stacks/common@latest ``` diff --git a/content/docs/stacks/stacks.js/packages/network.mdx b/content/docs/stacks/stacks.js/packages/network.mdx index 3b47df49..99458c2d 100644 --- a/content/docs/stacks/stacks.js/packages/network.mdx +++ b/content/docs/stacks/stacks.js/packages/network.mdx @@ -15,7 +15,7 @@ import { InlineCode } from '@/components/inline-code'; import { Callout } from "@/components/callout"; -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.js—it'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. @@ -29,7 +29,7 @@ For example, instead of `STACKS_MAINNET`, simply use the string `"mainnet"` as t ```package-install -@stacks/network@next +@stacks/network@latest ``` ## Usage diff --git a/content/docs/stacks/stacks.js/roadmap.mdx b/content/docs/stacks/stacks.js/roadmap.mdx index 34653ab8..7a5d92fd 100644 --- a/content/docs/stacks/stacks.js/roadmap.mdx +++ b/content/docs/stacks/stacks.js/roadmap.mdx @@ -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. -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 ``` @@ -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] @@ -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'`. @@ -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. @@ -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.