Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for release v1.2 #505

Merged
merged 6 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api/tooling/create-gear-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Introducing Gear React Application Template: Accelerate Your Decentralized App D

Are you looking to swiftly launch your decentralized application (dApp) on Gear-powered blockchains? Look no further! Gear React Application Template, also known as `create-gear-app`, is a pre-configured application template designed to streamline the development process. With its well-thought-out infrastructure and convenient features, it allows developers to quickly create and deploy their dApps on Gear-powered blockchains.

Gear React Application Template can be found on [GitHub](https://github.com/gear-dapps/react-app). This template is packed with a range of benefits and features that make it an ideal choice for developers seeking efficiency and simplicity in their dApp development workflow.
Gear React Application Template can be found on [GitHub](https://github.com/gear-foundation/dapps-react-app). This template is packed with a range of benefits and features that make it an ideal choice for developers seeking efficiency and simplicity in their dApp development workflow.

## Features

Expand All @@ -32,5 +32,5 @@ Furthermore, Gear React Application Template is particularly beneficial for deve
Simply clone this repo to your local folder:

```sh
git clone https://github.com/gear-dapps/react-app.git d-app
git clone https://github.com/gear-foundation/dapps-react-app.git d-app
```
6 changes: 4 additions & 2 deletions docs/developing-contracts/interactions-between-programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ async fn main() {
To send a message to a Gear program, use the `send_for_reply(program, payload, value)` function. In this function:
- program - the address of the program to send the message for;
- payload - the message to the program;
- value - the funds attached to the message.
- value - the funds attached to the message;
- reply_deposit - used to provide gas for future reply handling (skipped if zero).

```rust
pub fn send_for_reply_as<E: Encode, D: Decode>(
program: ActorId,
payload: E,
value: u128
value: u128,
reply_deposit: u64
) -> Result<CodecMessageFuture<D>>
```
2 changes: 1 addition & 1 deletion docs/developing-contracts/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Let's explore the typical lifecycle of a Gear smart contract. We will use the Ru

You can find the minimal example in the [Getting Started](/docs/getting-started-in-5-minutes.md) section. It is a simple program that stores the counter, can increment and decrement it, and return the current value of the counter.

More advanced examples can be found in the Gear dApps organization on GitHub: https://github.com/gear-dapps
More advanced examples can be found in the Gear Fooundation organization on GitHub: https://github.com/gear-foundation

**Step 2.** Test the program.

Expand Down
20 changes: 3 additions & 17 deletions docs/developing-contracts/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Metadata for ProgramMetadata {
type Init = InOut<MessageInitIn, MessageInitOut>;
type Handle = InOut<MessageIn, MessageOut>;
type Others = InOut<MessageAsyncIn, Option<u8>>;
type Reply = InOut<String, Vec<u16>>;
type Reply = String;
type Signal = ();
type State = Vec<Wallet>;
}
Expand All @@ -34,8 +34,8 @@ As we can see, metadata enables you to determine the expected data at the input/

- `Init` - describes incoming/outgoing types for `init()` function.
- `Handle` - describes incoming/outgoing types for `handle()` function.
- `Others` - describes incoming/outgoing types for `main()` function in case of asyncronius interaction.
- `Reply` - describes incoming/outgoing types of message performed using the `handle_reply` function.
- `Others` - describes incoming/outgoing types for `main()` function in case of asynchronous interaction.
- `Reply` - describes an incoming type of message performed using the `handle_reply` function.
- `Signal` - describes only the outgoing type from the program while processing the system signal.
- `State` - describes the types for the queried State

Expand All @@ -59,17 +59,3 @@ As a result of the smart-contract compilation, a `meta.txt` file will be generat
```
01000000000103000000010500000001090000000102000000010d000000010f0000000111000000000112000000a9094c00083064656d6f5f6d6574615f696f344d657373616765496e6974496e0000080118616d6f756e74040108753800012063757272656e6379080118537472696e6700000400000503000800000502000c083064656d6f5f6d6574615f696f384d657373616765496e69744f7574000008013465786368616e67655f72617465100138526573756c743c75382c2075383e00010c73756d04010875380000100418526573756c740804540104044501040108084f6b040004000000000c457272040004000001000014083064656d6f5f6d6574615f696f244d657373616765496e000004010869641801084964000018083064656d6f5f6d6574615f696f084964000008011c646563696d616c1c010c75363400010c68657820011c5665633c75383e00001c000005060020000002040024083064656d6f5f6d6574615f696f284d6573736167654f7574000004010c7265732801384f7074696f6e3c57616c6c65743e00002804184f7074696f6e040454012c0108104e6f6e6500000010536f6d6504002c00000100002c083064656d6f5f6d6574615f696f1857616c6c6574000008010869641801084964000118706572736f6e300118506572736f6e000030083064656d6f5f6d6574615f696f18506572736f6e000008011c7375726e616d65080118537472696e670001106e616d65080118537472696e6700003400000238003800000504003c083064656d6f5f6d6574615f696f384d6573736167654173796e63496e0000040114656d707479400108282900004000000400004404184f7074696f6e04045401040108104e6f6e6500000010536f6d650400040000010000480000022c00
```

## Verify metadata

To make it possible to verify metadata for a program, you can use the `metahash()` function. It allows verifying metadata on-chain.

```rust
#[no_mangle]
// It returns the Hash of metadata.
// .metahash is generating automatically while you are using build.rs
extern "C" fn metahash() {
let metahash: [u8; 32] = include!("../.metahash");
msg::reply(metahash, 0).expect("Failed to share metahash");
}
```
3 changes: 2 additions & 1 deletion docs/developing-contracts/system-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ If gas has been reserved but no system messages occur during the current executi

It can be useful for a developer when writing communication between programs. Developer can define `my_handle_signal` function and implement some logic there. For example, `Program A` sent a message to `Program B`. `Program A` is waiting for a reply from `Program B` but `Program B` runs out of gas. The current execution will be interrupted, but the system will send a signal to `Program A` and indicates the message identifier during which the execution was interrupted.
So, `Program A` sends a message and saves the message identifier:

```rust
exec::system_reserve_gas(2_000_000_000).expect("Error during system gas reservation");
let result = msg::send_for_reply(address, payload, value);
let result = msg::send_for_reply(address, payload, value, reply_deposit);

let (msg_id, msg_future) = if let Ok(msg_future) = result {
(msg_future.waiting_reply_to, msg_future)
Expand Down
6 changes: 3 additions & 3 deletions docs/developing-contracts/testing-gclient.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ authors = ["Your Name"]
edition = "2021"

[dependencies]
gstd = { git = "https://github.com/gear-tech/gear.git", features = ["debug"], branch = "stable" }
gstd = { git = "https://github.com/gear-tech/gear.git", features = ["debug"], rev = "946ac47" }

[build-dependencies]
gear-wasm-builder = { git = "https://github.com/gear-tech/gear.git", branch = "stable" }
gear-wasm-builder = { git = "https://github.com/gear-tech/gear.git", rev = "946ac47" }

[dev-dependencies]
gclient = { git = "https://github.com/gear-tech/gear.git", branch = "stable" }
gclient = { git = "https://github.com/gear-tech/gear.git", rev = "946ac47" }
tokio = { version = "1.23.0", features = ["full"] }

[patch.crates-io]
Expand Down
6 changes: 3 additions & 3 deletions docs/developing-contracts/testing-gtest.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ authors = ["Your Name"]
edition = "2021"

[dependencies]
gstd = { git = "https://github.com/gear-tech/gear.git", branch = "stable" }
gstd = { git = "https://github.com/gear-tech/gear.git", rev = "946ac47" }

[build-dependencies]
gear-wasm-builder = { git = "https://github.com/gear-tech/gear.git", branch = "stable" }
gear-wasm-builder = { git = "https://github.com/gear-tech/gear.git", rev = "946ac47" }

[dev-dependencies]
gtest = { git = "https://github.com/gear-tech/gear.git", branch = "stable" }
gtest = { git = "https://github.com/gear-tech/gear.git", rev = "946ac47" }
```

## `gtest` capabilities
Expand Down
21 changes: 10 additions & 11 deletions docs/examples/DAO.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ DAOs offer safe alternatives to pooling together money for a particular cause. B

### DAO application example by Gear

Anyone can easily create their own DAO application and run it on the Gear Network. To do this, Gear created an example of the DAO smart contract, which is available on [GitHub](https://github.com/gear-dapps/dao-light).
Anyone can easily create their own DAO application and run it on the Gear Network. To do this, Gear created an example of the DAO smart contract, which is available on [GitHub](https://github.com/gear-foundation/dapps-dao-light).

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.

<!-- In addition, Gear provides an example implementation of the DAO user interface to demonstrate its interaction with the smart contract 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-dapps/dao-app).
<!-- In addition, Gear provides an example implementation of the DAO user interface to demonstrate its interaction with the smart contract 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
Expand Down Expand Up @@ -80,8 +80,7 @@ where:
`transactions` - the transaction history.


Parameters `approved_token_program_id`, `period_duration`, `grace_period_length` are set when initializing a contract. The contract is initialized
with the following struct:
Parameters `approved_token_program_id`, `period_duration`, `grace_period_length` are set when initializing a contract. The contract is initialized with the following struct:

```rust
struct InitDao {
Expand Down Expand Up @@ -232,15 +231,15 @@ The `DAO` contract interacts with the `fungible` token contract. Each transactio
<!--
## 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-dapps/dao-light) and [gFT](https://github.com/gear-dapps/fungible-token) smart contracts.
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) smart contracts.
Gear Fundible Token enables creation of utility token DAO, check [this article](gft-20.md) for details.
This video demonstrates the entire configuration and user interaction workflow: **https://youtu.be/6lxr7eojADw**
![img alt](./img/dao-1.jpg)
A DAO application source code is available on [GitHub](https://github.com/gear-dapps/dao-app).
A DAO application source code is available on [GitHub](https://github.com/gear-foundation/dapps-dao-app).
### Configure basic dApp in .env:
Expand All @@ -254,7 +253,7 @@ REACT_APP_CONTRACT_DAO
- `REACT_APP_CONTRACT_ERC` is Fundible Token contract address
- `REACT_APP_CONTRACT_DAO` is DAO contract address
An example is available: [here](https://github.com/gear-dapps/dao-app/blob/master/.env.example)
An example is available: [here](https://github.com/gear-foundation/dapps-dao-app/blob/master/.env.example)
### How to run
Expand Down Expand Up @@ -300,7 +299,7 @@ extern "C" fn state() {
.expect("Failed to share state");
}
```
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `DaoState` state. For example - [gear-dapps/dao/state](https://github.com/gear-dapps/dao/tree/master/state):
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `DaoState` state. For example - [gear-foundation/dapps-dao/state](https://github.com/gear-foundation/dapps-dao/tree/master/state):

```rust
#[metawasm]
Expand Down Expand Up @@ -330,11 +329,11 @@ pub trait Metawasm {
```

## Source code
The source code of this example of DAO smart contract and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-dapps/dao-light).
The source code of this example of DAO smart contract and the example of an implementation of its testing is available on [GitHub](https://github.com/foundation/dapps-dao-light).

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

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

For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article.
8 changes: 4 additions & 4 deletions docs/examples/concert.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sidebar_position: 14

This smart contract example created by Gear represents a Concert tickets distribution with the idea of converting fungible tokens (gFT) to non-fungible tokens (gNFT) in time.

The 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. Anyone can easily create their own application and run it on the Gear Network. The source code is available on [GitHub](https://github.com/gear-dapps/concert).
The 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. Anyone can easily create their own application and run it on the Gear Network. The source code is available on [GitHub](https://github.com/gear-foundation/dapps-concert).

In this example, a single deployed contract can hold one concert at a time. Firstly, all the tickets for the concert come as fungible-tokens. In order to buy tickets one should provide the metadata (e.g. seat/row number) that will later be included in NFTs. When the concert ends, all the fungible tokens of all users (ticket holders) will turn into NFTs.

Expand Down Expand Up @@ -122,7 +122,7 @@ extern "C" fn state() {
.expect("Failed to encode or reply with `<ContractMetadata as Metadata>::State` from `state()`");
}
```
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `State` struct. For example - [gear-dapps/concert/state](https://github.com/gear-dapps/concert/tree/master/state):
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `State` struct. For example - [gear-foundation/dapps-concert/state](https://github.com/gear-foundation/dapps-concert/tree/master/state):

```rust
#[metawasm]
Expand All @@ -144,8 +144,8 @@ pub trait Metawasm {
```

## Conclusion
A source code of the contract example provided by Gear is available on GitHub: [`concert/src`](https://github.com/gear-dapps/concert/tree/master/src).
A source code of the contract example provided by Gear is available on GitHub: [`concert/src`](https://github.com/gear-foundation/dapps-concert/tree/master/src).

See also an example of the smart contract testing implementation based on [gtest](https://github.com/gear-dapps/concert/tree/master/tests).
See also an example of the smart contract testing implementation based on [gtest](https://github.com/gear-foundation/dapps-concert/tree/master/tests).

For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing).
13 changes: 7 additions & 6 deletions docs/examples/crowdsale.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A public offering to invest in a brand-new cryptocurrency or other digital asset

An example of a crowdsale smart-contract implementation described in this article is one of many other decentralized applications that can be implemented and launched on Gear. 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. Anyone can easily create their own crowdsale application and run it on the Gear Network.

Initial funds with which a token is purchased are determined by the Gear fungible tokens contract - [gFT](https://wiki.gear-tech.io/examples/gft-20). The contract's source code is available on [GitHub](https://github.com/gear-dapps/crowdsale).
Initial funds with which a token is purchased are determined by the Gear fungible tokens contract - [gFT](https://wiki.gear-tech.io/examples/gft-20). The contract's source code is available on [GitHub](https://github.com/gear-foundation/dapps-crowdsale).

## Interface
### Source files
Expand All @@ -23,7 +23,7 @@ pub async fn transfer_tokens(
from: &ActorId, // - the sender address
to: &ActorId, // - the recipient address
amount: u128, // - the amount of tokens
)
)
```
This function sends a message (the action is defined in the enum IcoAction) and gets a reply (the reply is defined in the enum IcoEvent):
```rust
Expand All @@ -39,13 +39,14 @@ let _transfer_response = msg::send_for_reply_as::<ft_main_io::FTokenAction, FTok
.encode(),
},
0,
0,
)
.expect("Error in sending a message `FTokenAction::Message`")
.await
.expect("Error int transfer");
```

2. `asserts.rs` - contains asserts functions: `owner_message` and `not_zero_address`.
2. `asserts.rs` - contains asserts functions: `owner_message` and `not_zero_address`.
- `owner_message` checks if `msg::source()` is equal to `owner`. Otherwise, it panics:
```rust
pub fn owner_message(owner: &ActorId, message: &str) {
Expand Down Expand Up @@ -106,7 +107,7 @@ pub struct IcoState {
- `tokens_sold` - how many tokens were sold
- `tokens_goal` - how many tokens are we going to sell
- `owner` - contract owner
- `token_address` - fungible token address
- `token_address` - fungible token address
- `token_holders` - the list of buyers and the number of tokens they bought

### Functions
Expand Down Expand Up @@ -173,7 +174,7 @@ extern "C" fn state() {
);
}
```
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `State` state. For example - [gear-dapps/crowdsale/state](https://github.com/gear-dapps/crowdsale/tree/master/state):
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `State` state. For example - [gear-foundation/dapps-crowdsale/state](https://github.com/gear-foundation/dapps-crowdsale/tree/master/state):

```rust
#[metawasm]
Expand All @@ -197,6 +198,6 @@ pub trait Metawasm {

## Conclusion

The source code of this example of ICO smart contract and the example of an implementation of its testing is available on [Github](https://github.com/gear-dapps/crowdsale).
The source code of this example of ICO smart contract and the example of an implementation of its testing is available on [Github](https://github.com/gear-foundation/dapps-crowdsale).

For more details about testing smart contracts written on Gear, refer to the [Program Testing](https://wiki.gear-tech.io/developing-contracts/testing) article.
Loading