From 227bd921137e645e9987c0b337f2f45186a719e2 Mon Sep 17 00:00:00 2001 From: ronny-mysten <118224482+ronny-mysten@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:01:47 -0600 Subject: [PATCH] [docs] Removing patterns (#17012) ## Description Removing patterns because they belong in move book. ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --- docs/content/concepts.mdx | 4 +-- docs/content/concepts/sui-move-concepts.mdx | 4 --- .../concepts/sui-move-concepts/patterns.mdx | 29 ------------------- .../developer/app-examples/coin-flip.mdx | 4 +-- .../developer/app-examples/weather-oracle.mdx | 2 +- .../developer/sui-101/simulating-refs.mdx | 2 +- docs/content/sidebars/concepts.js | 16 ---------- 7 files changed, 5 insertions(+), 56 deletions(-) delete mode 100644 docs/content/concepts/sui-move-concepts/patterns.mdx diff --git a/docs/content/concepts.mdx b/docs/content/concepts.mdx index 7a697d2034dd7..79b6f82ca8474 100644 --- a/docs/content/concepts.mdx +++ b/docs/content/concepts.mdx @@ -9,9 +9,7 @@ Sui is different than other blockchains. The concepts explored in this section p - - - + ## Objects diff --git a/docs/content/concepts/sui-move-concepts.mdx b/docs/content/concepts/sui-move-concepts.mdx index b94894e839b00..1f5e237a1833f 100644 --- a/docs/content/concepts/sui-move-concepts.mdx +++ b/docs/content/concepts/sui-move-concepts.mdx @@ -84,7 +84,3 @@ Move does not have a native type for strings, but it has a useful wrapper. See [ ### One-time witness A one-time witness (OTW) is a special instance of a type created in the module initializer and guaranteed to be unique with only one instance. See [One-Time Witness](./sui-move-concepts/one-time-witness.mdx) for an example. - -### Patterns - -Move coding patterns, or techniques, solve logic problems you encounter when developing Move packages for the Sui blockchain. See the [Patterns](./sui-move-concepts/patterns.mdx) section for a list of documented coding patterns. diff --git a/docs/content/concepts/sui-move-concepts/patterns.mdx b/docs/content/concepts/sui-move-concepts/patterns.mdx deleted file mode 100644 index f569225841926..0000000000000 --- a/docs/content/concepts/sui-move-concepts/patterns.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: Patterns -description: Move coding patterns, or techniques, solve logic problems you encounter when developing Move packages for the Sui blockchain. These include capabilities, witness and transferrable witness, hot potato, and ID pointer. ---- - -Topics in this section introduce Move coding patterns that solve various logic needs in your package development. - -## Capabilities - -A capability is a pattern that allows authorizing actions with an object. See [Capabilities](./patterns/capabilities.mdx) for an example of this pattern. - -## Witness and transferrable witness - -A witness is a type with `drop` that proves that its owner was present at the time of some privileged operation, for example having access to the one-time witness (OTW) for a module proves that the code is being run at the time the module was first published. See the following topics for details. - -- [Witness](./patterns/witness) -- [Transferrable Witness](./patterns/transferrable-witness) - -## Hot potato - -A hot potato is a struct that has no capabilities, therefore you can only pack and unpack it in its module. - -- [Hot Potato](./patterns/hot-potato) - -## ID pointer - -Objects can refer to each other by using their IDs as pointers. For example a capability that guards access to another object may store that object's `ID` to perform an authorization check. - -- [ID Pointer](./patterns/id-pointer) diff --git a/docs/content/guides/developer/app-examples/coin-flip.mdx b/docs/content/guides/developer/app-examples/coin-flip.mdx index 305421eb078c4..a3901f461857a 100644 --- a/docs/content/guides/developer/app-examples/coin-flip.mdx +++ b/docs/content/guides/developer/app-examples/coin-flip.mdx @@ -87,8 +87,8 @@ Next, add some more code to this module: ``` - The first struct, `HouseData`, stores the most essential information pertaining to the game. -- The second struct, `HouseCap`, is a [capability](concepts/sui-move-concepts/patterns/capabilities.mdx) that initializes the house data. -- The third struct, `HOUSE_DATA`, is a [one-time witness](concepts/sui-move-concepts/one-time-witness.mdx) that ensures only a single instance of this `HouseData` ever exists. +- The second struct, `HouseCap`, is a capability that initializes the house data. +- The third struct, `HOUSE_DATA`, is a one-time witness that ensures only a single instance of this `HouseData` ever exists. - The [`init` function](concepts/sui-move-concepts/init.mdx) creates and sends the `Publisher` and `HouseCap` objects to the sender. So far, you've set up the data structures within the module. Now, create a function that initializes the house data and shares the `HouseData` object: diff --git a/docs/content/guides/developer/app-examples/weather-oracle.mdx b/docs/content/guides/developer/app-examples/weather-oracle.mdx index 8606d4395e8cb..c296ac2396953 100644 --- a/docs/content/guides/developer/app-examples/weather-oracle.mdx +++ b/docs/content/guides/developer/app-examples/weather-oracle.mdx @@ -98,7 +98,7 @@ fun init(otw: WEATHER, ctx: &mut TxContext) { } ``` -- The first struct, `AdminCap`, is a [capability](concepts/sui-move-concepts/patterns/capabilities.mdx). +- The first struct, `AdminCap`, is a capability. - The second struct, `WEATHER`, is a [one-time witness](concepts/sui-move-concepts/one-time-witness.mdx) that ensures only a single instance of this `Weather` ever exists. - The `WeatherOracle` struct works as a registry and stores the `geoname_id`s of the `CityWeatherOracle`s as [dynamic fields](concepts/dynamic-fields.mdx). - The [`init` function](concepts/sui-move-concepts/init.mdx) creates and sends the `Publisher` and `AdminCap` objects to the sender. Also, it creates a [shared object](concepts/object-ownership/shared.mdx) for all the `CityWeatherOracle`s. diff --git a/docs/content/guides/developer/sui-101/simulating-refs.mdx b/docs/content/guides/developer/sui-101/simulating-refs.mdx index 38ba065d6397f..7b9a6de3309c0 100644 --- a/docs/content/guides/developer/sui-101/simulating-refs.mdx +++ b/docs/content/guides/developer/sui-101/simulating-refs.mdx @@ -17,7 +17,7 @@ Programmable transaction blocks (PTBs) do not currently allow the use of object ## The borrow module -The Sui framework includes a [borrow](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/borrow.md) module that offers a solution to the reference problem. The module provides access to an object by value but builds a model that makes it impossible to destroy, transfer, or wrap the object retrieved. The borrow module exposes a `Referent` object that wraps another object (the object you want to reference). The module uses the [hot potato pattern](/concepts/sui-move-concepts/patterns/hot-potato.mdx) (via a `Borrow` instance) to allow retrieval of the wrapped object by value. Within the same PTB, the module then forces the object to be returned to the `Referent`. The `Borrow` instance guarantees that the object returned is the same that was retrieved. +The Sui framework includes a [borrow](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/borrow.md) module that offers a solution to the reference problem. The module provides access to an object by value but builds a model that makes it impossible to destroy, transfer, or wrap the object retrieved. The borrow module exposes a `Referent` object that wraps another object (the object you want to reference). The module uses the hot potato pattern (via a `Borrow` instance) to allow retrieval of the wrapped object by value. Within the same PTB, the module then forces the object to be returned to the `Referent`. The `Borrow` instance guarantees that the object returned is the same that was retrieved. As an example, consider the following module stub that exposes an object (`Asset`) and a function (`use_asset`) to use that object. diff --git a/docs/content/sidebars/concepts.js b/docs/content/sidebars/concepts.js index c5e4a4cf2c341..3ff1dafdf5a7a 100644 --- a/docs/content/sidebars/concepts.js +++ b/docs/content/sidebars/concepts.js @@ -82,22 +82,6 @@ const concepts = [ 'concepts/sui-move-concepts/packages/custom-policies', ], }, - { - type: 'category', - label: 'Patterns', - link: { - type: 'doc', - id: 'concepts/sui-move-concepts/patterns', - }, - items: [ - 'concepts/sui-move-concepts/patterns/capabilities', - 'concepts/sui-move-concepts/patterns/witness', - 'concepts/sui-move-concepts/patterns/transferrable-witness', - 'concepts/sui-move-concepts/patterns/hot-potato', - 'concepts/sui-move-concepts/patterns/id-pointer', - 'concepts/sui-move-concepts/patterns/app-extensions', - ], - }, 'concepts/sui-move-concepts/conventions', ], },