Skip to content

Commit

Permalink
fix(docs/content): Move related documentation enhancement (#1864)
Browse files Browse the repository at this point in the history
* feat(docs): Create an examples folder for Rust code (#1503)

* feat(docs): create an example folder for Rust code

* Update docs/examples/rust/Cargo.toml

---------

Co-authored-by: Dr-Electron <[email protected]>

* fix(docs/examples): remove base_keystore example

* feat(iota-sdk): added an alias output claim example (#1493)

* feat(iota-sdk): added an alias output claim example

* feat(docs): moved the alias output claim example

* refactor(docs): used the extract_and_send_to function to simplify the example

* fix(docs): added a license header and an example description

* fix(docs): alias-output-claim comments

* fix(docs): clippy

* fix(docs): move the alias-output-claim example into the stardust subfolder

* fix(docs): fixed the example after rebasing

* fix(docs): move the alias-output-claim example

* fix(docs): alias-output-claim logs improved

* feat(iota-sdk): add basic output claim example

* fix(iota-sdk): use the proper native token bag key

* fix(iota-sdk): move basic output example in docs

* fix(docs/examples): comments

* fix(docs/examples): license header

* fix(docs/examples): basic output address

* fix(docs/examples): fix clippy

* fix(docs/examples): fix from comments

* fix(docs/examples): move basic output example

* fix(docs/examples): remove src folder

* feat(docs/examples): nft output extraction example based on sdk (#1478)

* feat(docs): add nft output claiming test example based on sdk usage

* feat(ci): add docs examples in rust (#1539)

* fix(docs/examples): add license

* fix(docs/examples): cargo lock

* chore(docs/examples): add clarification comment

* feat(docs/examples): add unlock condition example based on rust sdk (#1559)

* feat(docs): add unlock condition example based on rust sdk
Add fund_address function for sponsoring the main transaction

* feat(docs/examples): Add foundry output claim example (#1575)

* feat(docs/examples): ad foundry output claim

* fix(docs/examples): cargo toml and clones

* feat(docs/examples): Test the positive scenarios for using an NFT object (#1615)

* Add example of third party simple nft package, PTB that creates custom nft from stardust::nft
Add a conversion function for custom NFTs to allow migrating custom NFTs from Stardust NFTs

* feat(docs/stardust): Add docs for basic output claim (#1639)

* feat(docs/stardust): add docs for basic output claim

* Update docs/examples/rust/stardust/check-basic-output-unlock-conditions.rs

Co-authored-by: Thoralf-M <[email protected]>

* Update docs/examples/rust/stardust/check-basic-output-unlock-conditions.rs

Co-authored-by: Thoralf-M <[email protected]>

---------

Co-authored-by: Thoralf-M <[email protected]>

* feat(docs/content): documentation - claim NFT Output (#1654)

* feat(docs/content): documentation - claim NFT Output

* fear(docs/content) example of conversion of a stardust NFT into a custom user's. (#1669)

* Add example ofr third party simple nft package, PTB that create custom nft from stardust::nft

* feat(examples/docs): Add a conversion function for custom NFTs to allow migrating custom NFTs from Stardust NFTs

* Add function that publishes random nft package via CLI.

* feat(examples): replace package publishing approach with iota-move-builder

* Fix chkecs

* Minor refactoring

* dprint fix

* Fix review comments

* feat(docs/content): add doc related to conversion of a NFT Output into sutom NFT

* Review comment fixes

* Fix Nft naming

* Fix review comments

---------

Co-authored-by: Mirko Zichichi <[email protected]>

* feat(docs): Using an Alias object test scenario (#1679)

* Add example ofr third party simple nft package, PTB that create custom nft from stardust::nft

* feat(examples/docs): Add a conversion function for custom NFTs to allow migrating custom NFTs from Stardust NFTs

* Add function that publishes random nft package via CLI.

* feat(examples): replace package publishing approach with iota-move-builder

* Fix chkecs

* Minor refactoring

* dprint fix

* Fix review comments

* feat(docs/content): add doc related to conversion of a NFT Output into sutom NFT

* feat(docs): extended the custom_nft package with collections

* Review comment fixes

* Fix Nft naming

* fix(docs): NFTs conversion docs were fixed after refactoring

* fix(docs): spelling issues

---------

Co-authored-by: Dkwcs <[email protected]>

* refactor(docs/content): Split claiming docs in a tree (#1710)

* refactor(docs/content): split claiming docs in a tree

* feat(docs/content): add address unlock condition claim

* fix(docs/content): claiming references

* fix(docs/content): claiming references 2

* chore(docs): fix doc tree for claiming

---------

Co-authored-by: Levente Pap <[email protected]>

* feat(docs): Alias usage documentation was added (#1723)

* Add example ofr third party simple nft package, PTB that create custom nft from stardust::nft

* feat(examples/docs): Add a conversion function for custom NFTs to allow migrating custom NFTs from Stardust NFTs

* Add function that publishes random nft package via CLI.

* feat(examples): replace package publishing approach with iota-move-builder

* Fix chkecs

* Minor refactoring

* dprint fix

* Fix review comments

* feat(docs/content): add doc related to conversion of a NFT Output into sutom NFT

* feat(docs): extended the custom_nft package with collections

* Review comment fixes

* Fix Nft naming

* fix(docs): NFTs conversion docs were fixed after refactoring

* fix(docs): spelling issues

* feat(docs): added alias documentation

* fix(docs): spelling issues

* fix(docs): review comments

---------

Co-authored-by: Dkwcs <[email protected]>

* feat(docs/content): docs implementation for address unlock condition example (#1706)

* feat(docs/content): docs impl for address unlock condition

* feat(docs/content): Create example doc for claiming a Foundry Output (#1724)

* feat(docs/content): add doc example of claiming foundry output

* fix(docs/content): enhance claiming and fix links (#1768)

* feat(docs/examples): Add self sponsor example for Shimmer assets (#1772)

* feat(docs/examples): add self sponsor example

* fix(docs/content): make self sponsor example for Shimmer

* fix(docs/examples): smr comment

* fix(docs/examples): dprint

* fix(docs/examples): remove double comment

Co-authored-by: Thoralf-M <[email protected]>

* fix(docs/examples): client server comments

---------

Co-authored-by: Thoralf-M <[email protected]>

* feat(docs/content): Add Shimmer self-sponsorship claim docs (#1773)

* feat(docs/examples): add self sponsor example

* fix(docs/content): make self sponsor example for Shimmer

* fix(docs/examples): smr comment

* fix(docs/examples): dprint

* feat(docs/content): add shimmer self-sponsorship claim

* fix(docs/content): spaces

Co-authored-by: Thoralf-M <[email protected]>

* fix(docs/content): code lines

---------

Co-authored-by: Thoralf-M <[email protected]>

* fix(docs/content): improvements of docs navigation by adding links (#1774)

* fix(docs/content): improvements of docs navigation by adding links

* fix(docs/content): add additional links, readable improvements.

* fix(docs/content/../claiming): simplify navigation with additional links for OTW, Bag, Coin, Unlock Condition

* refactor(docs/examples): Create a utility methods lib (#1821)

* refactor(docs/examples): create a utility methods lib

* refactor(docs/examples): update examples

* refactor(docs/content): update examples code lines in docs

* fix(docs/examples): move module path

* fix(docs/examples): address uc name

* Update docs/examples/rust/src/lib.rs

Co-authored-by: Thoralf-M <[email protected]>

* Update docs/content/developer/stardust/claiming/nft.mdx

Co-authored-by: Thoralf-M <[email protected]>

* fix(docs/examples): move utils out of lib

---------

Co-authored-by: Thoralf-M <[email protected]>

* fix(docs/content): add links to simplify docs navigation

* feat(docs): Move content was fixed in the Developer/Getting Started documentation part

* fix(docs/context): add links, minor docs refactoring

* fix(docs/content): documentation code examples enhancement

* fix(docs): fixed tokenomics link

---------

Co-authored-by: Mirko Zichichi <[email protected]>
Co-authored-by: Dr-Electron <[email protected]>
Co-authored-by: Valerii Reutov <[email protected]>
Co-authored-by: Thoralf-M <[email protected]>
Co-authored-by: Levente Pap <[email protected]>
Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
7 people authored Aug 22, 2024
1 parent 7acbe9f commit e6f96d5
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 227 deletions.
283 changes: 165 additions & 118 deletions docs/content/developer/getting-started/first-app/build-test.mdx

Large diffs are not rendered by default.

42 changes: 23 additions & 19 deletions docs/content/developer/getting-started/first-app/debug.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ Alternatively, any call to abort or assertion failure also prints the stacktrace
To see the module in action, update your `my_module` code to include debug calls. Specifically, update the `new_sword` function so that you print the value of `forge` before and after updating `swords_created`. Also, include a `print_stack_trace` so that the function looks like the following:

```move
public fun new_sword(
forge: &mut Forge,
magic: u64,
strength: u64,
ctx: &mut TxContext,
): Sword {
/// Constructor for creating swords.
public fun new_sword(forge: &mut Forge, magic: u64, strength: u64, ctx: &mut TxContext): Sword {
debug::print(forge);
// Increment the `swords_created` counter.
forge.swords_created = forge.swords_created + 1;
debug::print(forge);
debug::print_stack_trace();
// Create a sword.
Sword {
id: object::new(ctx),
magic: magic,
Expand All @@ -55,7 +56,7 @@ public fun new_sword(
To see the results, run the module's tests.

```shell
$ iota move test
$ iota move test test_sword_transactions
```

The response prints out the expected results as the test calls the `new_sword` function.
Expand All @@ -65,7 +66,6 @@ INCLUDING DEPENDENCY Iota
INCLUDING DEPENDENCY MoveStdlib
BUILDING my_first_package
Running Move unit tests
[ PASS ] 0x0::my_module::test_module_init
[debug] 0x0::my_module::Forge {
id: 0x2::object::UID {
id: 0x2::object::ID {
Expand All @@ -86,25 +86,29 @@ Call Stack:
[0] 0000000000000000000000000000000000000000000000000000000000000000::my_module::test_sword_transactions

Code:
[19] LdU64(7)
[20] MutBorrowLoc(3)
[21] Call(14)
> [22] Call(4)
[23] LdConst(1)
[24] CallGeneric(2)
[25] ImmBorrowLoc(3)
[24] LdU64(7)
[25] CopyLoc(5)
[26] Call(13)
> [27] Call(6)
[28] CopyLoc(4)
[29] CallGeneric(2)
[30] CopyLoc(5)

Locals:
[0] -
[1] { { { <OBJECT-ID-WITHOUT-0x> } }, 1 }
[2] -
[3] { 2, { 00000000000000000000000000000000000000000000000000000000000000ad, [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0, 0, 0 } }
[1] -
[2] 000000000000000000000000000000000000000000000000000000000000face
[3] { { { <OBJECT-ID-WITHOUT-0x> } }, 1 }
[4] 000000000000000000000000000000000000000000000000000000000000cafe
[5] (&) { 1, { 000000000000000000000000000000000000000000000000000000000000babe, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0, 0, 0 } }
[6] { 1, { 000000000000000000000000000000000000000000000000000000000000babe, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0, 0, 0 } }
[7] -


Operand Stack:

[ PASS ] 0x0::my_module::test_sword_transactions
Test result: OK. Total tests: 2; passed: 2; failed: 0
Test result: OK. Total tests: 1; passed: 1; failed: 0
```
## Related links
Expand Down
14 changes: 7 additions & 7 deletions docs/content/developer/getting-started/first-app/publish.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ $ iota client objects
╭───────────────────────────────────────────────────────────────────────────────────────╮
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ <OBJECT-ID> │ │
│ │ version │ 10 │ │
│ │ version │ 3 │ │
│ │ digest │ <DIGEST-HASH> │ │
│ │ objectType │ <PACKAGE-ID>::my_module::Forge │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ <OBJECT-ID> │ │
│ │ version │ 10 │ │
│ │ version │ 3 │ │
│ │ digest │ <DIGEST-HASH> │ │
│ │ objectType │ 0x0000..0002::coin::Coin │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ <OBJECT-ID> │ │
│ │ version │ 10 │ │
│ │ version │ 3 │ │
│ │ digest │ <DIGEST-HASH> │ │
│ │ objectType │ 0x0000..0002::package::UpgradeCap │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
Expand Down Expand Up @@ -124,25 +124,25 @@ After the transaction executes, you can check the status of the `Sword` object b
╭───────────────────────────────────────────────────────────────────────────────────────╮
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ <OBJECT-ID> │ │
│ │ version │ 11 │ │
│ │ version │ 4 │ │
│ │ digest │ <DIGEST-HASH> │ │
│ │ objectType │ <PACKAGE-ID>::my_module::Forge │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ <OBJECT-ID> │ │
│ │ version │ 11 │ │
│ │ version │ 4 │ │
│ │ digest │ <DIGEST-HASH> │ │
│ │ objectType │ 0x0000..0002::coin::Coin │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ <OBJECT-ID> │ │
│ │ version │ 11 │ │
│ │ version │ 4 │ │
│ │ digest │ <DIGEST-HASH> │ │
│ │ objectType │ <PACKAGE-ID>::my_module::Sword │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ <OBJECT-ID> │ │
│ │ version │ 10 │ │
│ │ version │ 3 │ │
│ │ digest │ <DIGEST-HASH> │ │
│ │ objectType │ 0x0000..0002::package::UpgradeCap │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
Expand Down
19 changes: 9 additions & 10 deletions docs/content/developer/getting-started/first-app/write-package.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ Running the previous command creates a directory with the name you provide (`my_
```move title="my_first_package/Move.toml"
[package]
name = "my_first_package"
# edition = "2024.beta " # To use the Move 2024 edition, currently in beta
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]
[dependencies]
IOTA = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/iota-framework", rev = "framework/testnet" }
Iota = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/iota-framework", rev = "framework/testnet" }
# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
Expand Down Expand Up @@ -54,7 +53,7 @@ my_first_package = "0x0"
The manifest file contents include available sections of the manifest and comments that provide additional information. In Move, you prepend the hash mark (`#`) to a line to denote a comment.

- **[package]:** Contains metadata for the package. By default, the `iota move new` command populates only the `name` value of the metadata. In this case, the example passes `my_first_package` to the command, which becomes the name of the package. You can delete the first `#` of subsequent lines of the `[package]` section to provide values for the other available metadata fields.
- **[dependencies]:** Lists the other packages that your package depends on to run. By default, the `iota move new` command lists the `IOTA` package on GitHub (Testnet version) as the lone dependency.
- **[dependencies]:** Lists the other packages that your package depends on to run. By default, the `iota move new` command lists the `Iota` package on GitHub (Testnet version) as the lone dependency.
- **[addresses]:** Declares named addresses that your package uses. By default, the section includes the package you create with the `iota move new` command and an address of `0x0`. The publish process replaces the `0x0` address with an actual on-chain address.
- **[dev-dependencies]:** Includes only comments that describe the section.
- **[dev-addresses]:** Includes only comments that describe the section.
Expand Down Expand Up @@ -88,7 +87,7 @@ Populate the `my_module.move` file with the following code:
```move
module my_first_package::my_module {
// Part 1: Struct definitions
// Part 1: Struct definitions.
public struct Sword has key, store {
id: UID,
magic: u64,
Expand All @@ -100,17 +99,17 @@ module my_first_package::my_module {
swords_created: u64,
}
// Part 2: Module initializer to be executed when this module is published
// Part 2: Module initializer to be executed when this module is published.
fun init(ctx: &mut TxContext) {
let admin = Forge {
id: object::new(ctx),
swords_created: 0,
};
// Transfer the forge object to the module/package publisher
// Transfer the forge object to the module/package publisher.
transfer::public_transfer(admin, tx_context::sender(ctx));
}
// Part 3: Accessors required to read the struct attributes
// Part 3: Accessors required to read the struct attributes.
public fun magic(self: &Sword): u64 {
self.magic
}
Expand All @@ -123,9 +122,9 @@ module my_first_package::my_module {
self.swords_created
}
// Part 4: Public/entry functions (introduced later in the tutorial)
// Part 4: Public/entry functions (introduced later in the tutorial).
// Part 5: Private functions (if any)
// Part 5: Private functions (if any).
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/content/developer/iota-101/access-time.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module example::clock {
use iota::clock::{Self, Clock};
use iota::event;
struct TimeEvent has copy, drop, store {
public struct TimeEvent has copy, drop, store {
timestamp_ms: u64
}
Expand Down
15 changes: 3 additions & 12 deletions docs/content/developer/iota-101/create-coin/create-coin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ Publishing a coin on IOTA is nearly as straightforward as publishing a new type.

```move
module examples::mycoin {
use std::option;
use iota::coin::{Self, Coin, TreasuryCap};
use iota::transfer;
use iota::tx_context::{Self, TxContext};
use iota::coin::{Self, TreasuryCap};
/// The type identifier of coin. The coin will have a type
/// tag of kind: `Coin<package_object::mycoin::MYCOIN>`
/// Make sure that the name of the type matches the module's name.
struct MYCOIN has drop {}
public struct MYCOIN has drop {}
/// Module initializer is called once on module publish. A treasury
/// cap is sent to the publisher, who then controls minting and burning
Expand Down Expand Up @@ -66,13 +63,7 @@ Amount: <COIN-AMOUNT>

## DenyList

The IOTA framework provides a `DenyList` singleton, shared object that the bearer of a `DenyCap` can access to specify a list of addresses that are unable to use a IOTA core type. The initial use case for `DenyList`, however, focuses on limiting access to coins of a specified type. This is useful, for example, when creating a regulated coin on IOTA that requires the ability to block certain addresses from using it as inputs to transactions. Regulated coins on IOTA satisfy any regulations that require the ability to prevent known bad actors from having access to those coins.

:::info

The `DenyList` object is a system object that has the address `0x403`. You cannot create it yourself.

:::
See [`DenyList`](../create-coin/regulated.mdx#deny-list).

## Create regulated coin

Expand Down
15 changes: 5 additions & 10 deletions docs/content/developer/iota-101/create-coin/in-game-token.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ The following example creates an in-game currency called a GEM, which represents
/// that sells swords for Gems. Gems are an in-game currency that can be bought
/// with IOTA.
module examples::sword {
use iota::tx_context::TxContext;
use iota::object::{Self, UID};
use iota::token::{Self, Token, ActionRequest};
use examples::gem::GEM;
Expand All @@ -24,7 +21,7 @@ module examples::sword {
const SWORD_PRICE: u64 = 10;
/// A game item that can be purchased with Gems.
struct Sword has key, store { id: UID }
public struct Sword has key, store { id: UID }
/// Purchase a sword with Gems.
public fun buy_sword(
Expand All @@ -44,10 +41,8 @@ module examples::gem {
use std::option::none;
use std::string::{Self, String};
use iota::iota::IOTA;
use iota::transfer;
use iota::object::{Self, UID};
use iota::balance::{Self, Balance};
use iota::tx_context::{sender, TxContext};
use iota::tx_context::sender;
use iota::coin::{Self, Coin, TreasuryCap};
use iota::token::{Self, Token, ActionRequest};
Expand All @@ -70,7 +65,7 @@ module examples::gem {
#[allow(lint(coin_field))]
/// Gems can be purchased through the `Store`.
struct GemStore has key {
public struct GemStore has key {
id: UID,
/// Profits from selling Gems.
profits: Balance<IOTA>,
Expand All @@ -79,7 +74,7 @@ module examples::gem {
}
/// The OTW to create the in-game currency.
struct GEM has drop {}
public struct GEM has drop {}
// In the module initializer we create the in-game currency and define the
// rules for different types of actions.
Expand All @@ -91,7 +86,7 @@ module examples::gem {
);
// create a `TokenPolicy` for GEMs
let (policy, cap) = token::new_policy(&treasury_cap, ctx);
let (mut policy, cap) = token::new_policy(&treasury_cap, ctx);
token::allow(&mut policy, &cap, buy_action(), ctx);
token::allow(&mut policy, &cap, token::spend_action(), ctx);
Expand Down
Loading

0 comments on commit e6f96d5

Please sign in to comment.