Skip to content

Commit

Permalink
Replace html comments with md comments (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
ereburg committed Jun 3, 2024
1 parent a2f30a0 commit 4398aaa
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 92 deletions.
6 changes: 2 additions & 4 deletions docs/developing-contracts/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ Program deployment is a process of storing the program's Wasm code on the blockc

If initialization fails (for example, the program panics in the `init()` function), the program is not deployed and the user gets an error.

<!--
Also, it is important to underline that someone should pay rent for keeping the program in the blockchain after a free period that is equal to 5 million blocks (it is about 2 months for networks with 1 block per second production). It is possible to add funds for rent using the [`pay_program_rent`](https://docs.gear.rs/pallet_gear/pallet/struct.Pallet.html#method.pay_program_rent) extrinsic (by the user) or with the [`gstd::exec::pay_program_rent`](https://docs.gear.rs/gstd/exec/fn.pay_program_rent.html) API function (by the program). If the rent is not paid, the program state changes to pause, its persistent memory is removed from the storage and the program can't be executed. The program can be resumed by uploading its memory pages to the blockchain and paying the rent.
-->
[//]: # (Also, it is important to underline that someone should pay rent for keeping the program in the blockchain after a free period that is equal to 5 million blocks &#40;it is about 2 months for networks with 1 block per second production&#41;. It is possible to add funds for rent using the [`pay_program_rent`]&#40;https://docs.gear.rs/pallet_gear/pallet/struct.Pallet.html#method.pay_program_rent&#41; extrinsic &#40;by the user&#41; or with the [`gstd::exec::pay_program_rent`]&#40;https://docs.gear.rs/gstd/exec/fn.pay_program_rent.html&#41; API function &#40;by the program&#41;. If the rent is not paid, the program state changes to pause, its persistent memory is removed from the storage and the program can't be executed. The program can be resumed by uploading its memory pages to the blockchain and paying the rent.)

You can find more details about program deployment in the [Upload Program](./deploy.md) section.

Expand Down Expand Up @@ -223,4 +221,4 @@ Usually, the reply sender pays a gas fee for the reply message execution. But so

The reply deposit is a part of the gas limit reserved during the current execution to be spent later. The reserved gas can be used to pay for the reply message execution. To do this, the program should call the [`gstd::exec::reply_deposit`](https://docs.gear.rs/gstd/exec/fn.reply_deposit.html) function. This function provides a gas deposit from the current message to handle the reply message on the given message ID. This message ID should be sent within the execution. Once the destination actor or system sends a reply to it, the gas limit ignores it; if the program gives a deposit, only it will be used for the execution of `handle_reply`.

You can find more details about reply deposit in the [Reply Deposit](./reply-deposit.md) section.
You can find more details about reply deposit in the [Reply Deposit](./reply-deposit.md) section.
100 changes: 50 additions & 50 deletions docs/developing-contracts/testing-gtest.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,56 +220,56 @@ gtest = { git = "https://github.com/gear-tech/gear.git", tag = "v1.1.1" }
// Same for the timestamp. Note, that for now 1 block in Gear network is 1 sec duration.
sys.spend_blocks(150);
```
<!--
- Reading the program state:
```rust
// To read the program state you need to call one of two program's functions:
// `meta_state()` or `meta_state_with_bytes()`.
//
// The methods require the payload as the input argument.
//
// The first one requires payload to be CODEC Encodable, while the second requires payload
// implement `AsRef<[u8]>`, that means to be able to represent as bytes.
//
// Let we have the following program state and `meta_state` function:
#[derive(Encode, Decode, TypeInfo)]
pub struct ContractState {
a: u128,
b: u128,
}
pub enum State {
A,
B,
}
pub enum StateReply {
A(u128),
B(u128),
}
#[no_mangle]
unsafe extern "C" fn meta_state() -> *mut [i32; 2] {
let query: State = msg::load().expect("Unable to decode `State`");
let encoded = match query {
State::A => StateReply::A(STATE.a),
State::B => StateReply::B(STATE.b),
}.encode();
gstd::util::to_leak_ptr(encoded)
}
// Let's send a query from gtest:
let reply: StateReply = self
.meta_state(&State::A)
.expect("Meta_state failed");
let expected_reply = StateReply::A(10);
assert_eq!(reply,expected_reply);
// If your `meta_state` function doesn't require input payloads,
// you can use `meta_state_empty` or `meta_state_empty_with_bytes` functions
// without any arguments.
```
-->

[//]: # (- Reading the program state:)
[//]: # (```rust)
[//]: # ( // To read the program state you need to call one of two program's functions:)
[//]: # ( // `meta_state&#40;&#41;` or `meta_state_with_bytes&#40;&#41;`.)
[//]: # ( //)
[//]: # ( // The methods require the payload as the input argument.)
[//]: # ( //)
[//]: # ( // The first one requires payload to be CODEC Encodable, while the second requires payload)
[//]: # ( // implement `AsRef<[u8]>`, that means to be able to represent as bytes.)
[//]: # ( //)
[//]: # ( // Let we have the following program state and `meta_state` function:)
[//]: # ( #[derive&#40;Encode, Decode, TypeInfo&#41;])
[//]: # ( pub struct ContractState {)
[//]: # ( a: u128,)
[//]: # ( b: u128,)
[//]: # ( })
[//]: # ()
[//]: # ( pub enum State {)
[//]: # ( A,)
[//]: # ( B,)
[//]: # ( })
[//]: # ()
[//]: # ( pub enum StateReply {)
[//]: # ( A&#40;u128&#41;,)
[//]: # ( B&#40;u128&#41;,)
[//]: # ( })
[//]: # ()
[//]: # ( #[no_mangle])
[//]: # ( unsafe extern "C" fn meta_state&#40;&#41; -> *mut [i32; 2] {)
[//]: # ( let query: State = msg::load&#40;&#41;.expect&#40;"Unable to decode `State`"&#41;;)
[//]: # ( let encoded = match query {)
[//]: # ( State::A => StateReply::A&#40;STATE.a&#41;,)
[//]: # ( State::B => StateReply::B&#40;STATE.b&#41;,)
[//]: # ( }.encode&#40;&#41;;)
[//]: # ( gstd::util::to_leak_ptr&#40;encoded&#41;)
[//]: # ( })
[//]: # ()
[//]: # ( // Let's send a query from gtest:)
[//]: # ( let reply: StateReply = self)
[//]: # ( .meta_state&#40;&State::A&#41;)
[//]: # ( .expect&#40;"Meta_state failed"&#41;;)
[//]: # ( let expected_reply = StateReply::A&#40;10&#41;;)
[//]: # ( assert_eq!&#40;reply,expected_reply&#41;;)
[//]: # ()
[//]: # ( // If your `meta_state` function doesn't require input payloads,)
[//]: # ( // you can use `meta_state_empty` or `meta_state_empty_with_bytes` functions)
[//]: # ( // without any arguments.)
[//]: # (```)

- Balance:
```rust
// If you need to send a message with value you have to mint balance for the message sender:
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/Gaming/Battleship/battleship.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ At the session's conclusion, whether it's the end of the indicated window or whe

To initiate a session, a player sends a message to the program (assuming the program supports this message type):

<!-- TODO: Uncomment `title` after adding the code to the master branch -->
[//]: # ( TODO: Uncomment `title` after adding the code to the master branch )
```rust #title="battleship/src/contract.rs"
CreateSession {
key: ActorId,
Expand All @@ -421,7 +421,7 @@ where:

A session is structured as follows, allowing a player to set it up before starting the game:

<!-- TODO: Uncomment `title` after adding the code to the master branch -->
[//]: # ( TODO: Uncomment `title` after adding the code to the master branch )
```rust #title="battleship/src/contract.rs"
pub struct Session {
// the address of the player who will play on behalf of the user
Expand Down
91 changes: 57 additions & 34 deletions docs/examples/Governance/DAO.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ Anyone can easily create their own DAO application and run it on the Gear Networ

This article explains the programming interface, data structure, basic functions, and their purposes. You can use it as-is or modify it to suit your own scenarios.

<!-- In addition, Gear provides an example implementation of the DAO user interface to demonstrate its interaction with the program in the Gear Network. You can watch a video on how to get the DAO application up and running and its capabilities here: **https://youtu.be/6lxr7eojADw**. The source code for the DAO application is available on [GitHub](https://github.com/gear-foundation/dapps-dao-app).
-->

## Logic
The program has the following structs:

Expand Down Expand Up @@ -213,50 +210,77 @@ ProcessProposal {
did_pass: bool,
},
```
<!--
## Consistency of program states

The `DAO` program interacts with the `fungible token` program. Every transaction that alters the states of the DAO and the fungible token is recorded in the state until it is finalized. Users can complete a pending transaction by sending a `Continue` message along with the transaction ID. The idempotency feature of the fungible token program allows transactions to be restarted without duplicating changes, ensuring the state consistency of these two programs.
[//]: # ()
[//]: # (## Consistency of program states)

[//]: # ()
[//]: # (The `DAO` program interacts with the `fungible token` program. Every transaction that alters the states of the DAO and the fungible token is recorded in the state until it is finalized. Users can complete a pending transaction by sending a `Continue` message along with the transaction ID. The idempotency feature of the fungible token program allows transactions to be restarted without duplicating changes, ensuring the state consistency of these two programs.)

## User interface
[//]: # ()
[//]: # ()
[//]: # (## User interface)

A [Ready-to-Use application](https://dao.gear-tech.io/) example provides a user interface that interacts with [DAO](https://github.com/gear-foundation/dapps-dao-light) and [gFT](https://github.com/gear-foundation/dapps-fungible-token) programs.
[//]: # ()
[//]: # (A [Ready-to-Use application]&#40;https://dao.gear-tech.io/&#41; example provides a user interface that interacts with [DAO]&#40;https://github.com/gear-foundation/dapps-dao-light&#41; and [gFT]&#40;https://github.com/gear-foundation/dapps-fungible-token&#41; programs.)

Gear Fundible Token enables creation of utility token DAO, check [this article](../Standards/gft-20) for details.
[//]: # ()
[//]: # (Gear Fundible Token enables creation of utility token DAO, check [this article]&#40;../Standards/gft-20&#41; for details.)

This video demonstrates the entire configuration and user interaction workflow: **https://youtu.be/6lxr7eojADw**
[//]: # ()
[//]: # (This video demonstrates the entire configuration and user interaction workflow: **https://youtu.be/6lxr7eojADw**)

![img alt](./img/dao-1.jpg)
[//]: # ()
[//]: # (![img alt]&#40;./img/dao-1.jpg&#41;)

A DAO application source code is available on [GitHub](https://github.com/gear-foundation/dapps-dao-app).
[//]: # ()
[//]: # (A DAO application source code is available on [GitHub]&#40;https://github.com/gear-foundation/dapps-dao-app&#41;.)

### Configure basic dApp in .env:
[//]: # ()
[//]: # (### Configure basic dApp in .env:)

```sh
REACT_APP_NETWORK
REACT_APP_CONTRACT_ERC
REACT_APP_CONTRACT_DAO
```
[//]: # ()
[//]: # (```sh)

- `REACT_APP_NETWORK` is Gear network address (wss://rpc-node.gear-tech.io:443)
- `REACT_APP_CONTRACT_ERC` is Fundible Token contract address
- `REACT_APP_CONTRACT_DAO` is DAO program address
[//]: # (REACT_APP_NETWORK)

An example is available: [here](https://github.com/gear-foundation/dapps-dao-app/blob/master/.env.example)
[//]: # (REACT_APP_CONTRACT_ERC)

### How to run
[//]: # (REACT_APP_CONTRACT_DAO)

Install required dependencies:
```sh
yarn
```
[//]: # (```)

[//]: # ()
[//]: # (- `REACT_APP_NETWORK` is Gear network address &#40;wss://rpc-node.gear-tech.io:443&#41;)

[//]: # (- `REACT_APP_CONTRACT_ERC` is Fundible Token contract address)

[//]: # (- `REACT_APP_CONTRACT_DAO` is DAO program address)

[//]: # ()
[//]: # (An example is available: [here]&#40;https://github.com/gear-foundation/dapps-dao-app/blob/master/.env.example&#41;)

[//]: # ()
[//]: # (### How to run)

[//]: # ()
[//]: # (Install required dependencies:)

[//]: # (```sh)

[//]: # (yarn)

[//]: # (```)

[//]: # ()
[//]: # (Run:)

[//]: # (```sh)

[//]: # (yarn run start)

[//]: # (```)

Run:
```sh
yarn run start
```
-->

## Program metadata and state
Metadata interface description:
Expand Down Expand Up @@ -318,7 +342,6 @@ The source code for this DAO program example and its testing implementation are

The extended version of DAO that includes admin, membership proposals and delegated voting can be found at [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dao).

<!--The application source code is available in: [https://github.com/gear-foundation/dapps-dao-app](https://github.com/gear-foundation/dapps-dao-app).
-->
[//]: # (The application source code is available in: [https://github.com/gear-foundation/dapps-dao-app]&#40;https://github.com/gear-foundation/dapps-dao-app&#41;.)

For more details about testing programs written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article.
3 changes: 1 addition & 2 deletions docs/examples/NFTs/nft-marketplace/marketplace.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ yarn start

This article explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios.

<!-- You can watch a video on how to get the NFT Marketplace application up and running and its capabilities here: **https://youtu.be/4suveOT3O-Y**.
-->
[//]: # (You can watch a video on how to get the NFT Marketplace application up and running and its capabilities here: **https://youtu.be/4suveOT3O-Y**.)

## Logic
The program state:
Expand Down

0 comments on commit 4398aaa

Please sign in to comment.