Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
fiexer committed Jan 17, 2023
1 parent 9c5f086 commit bf7bbc9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Events are important for smart contracts because they facilitate communication b

## Minting Event
In our contract there is one occasion where an event should be emitted and that is when token is minted.
One could expect that by calling Openbrush `mint_to()`, and event will be emitted but upon closer examination we can see that `emit_transfer_event()` has empty default [implementation](https://github1s.com/Supercolony-net/openbrush-contracts/blob/main/contracts/src/token/psp34/psp34.rs#L151-L152). This gives flexibility to create events for our needs.
One could expect that by calling Openbrush `_mint_to()`, and event will be emitted but upon closer examination we can see that `_emit_transfer_event()` has empty default [implementation](https://github1s.com/Supercolony-net/openbrush-contracts/blob/main/contracts/src/token/psp34/psp34.rs#L151-L152). This gives flexibility to create events for our needs.

```rust
default fn _emit_transfer_event(&self, _from: Option<AccountId>, _to: Option<AccountId>, _id: Id) {}
```
Let's define two events that are needed for token handling, *Transfer* and *Approve*. This needs to be done in the contracts's `lib.rs`. Please note that there is no mint event. Mint is covered by *Transfer* event where `from` will be the contract address.
Let's define two events that are needed for token handling, *Transfer* and *Approve*. This needs to be done in the contracts's `lib.rs`. Please note that there is no `Mint` event. `Mint` is covered by *Transfer* event where `from` will be the contract address.
```rust
use ink_lang::codegen::{
EmitEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The `mint()` method now takes receiver NFT account and amount of tokens to be mi
This will allow contract to be in charge which token will be minted next and allows minting more than one token at the time.

### `set_base_uri(uri: PreludeString)`
First we need to import string from `ink_prelude` and rename it not to be mixed with Openbrush String Implementation. The difference is that Openbrush String is in fact a vector of u8 elements. Since we expect users to use `utf-8` string we use String from prelude.
First we need to import `String` from `ink_prelude` and rename it not to be mixed with Openbrush String Implementation. The difference is that Openbrush String is in fact a vector of u8 elements. Since we expect users to use `utf-8` string we use String from prelude.
```rust
use ink_prelude::string::String as PreludeString;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To create a smart contract which follows PSP34 standard use Openbrush Wizard:
1. Open [Openbrush.io](https://openbrush.io/) website and go to bottom of the page.
2. Select PSP34.
3. Select the version to match the rest of the tutorial. Check *What will be used* in the [prerequisites chapter](../nft.md).
4. Name your contract. In this tutorial we will use `Shiden34`.
4. Name your contract. In this tutorial we will use `shiden34`.
5. Select extensions: *Metadata*, *Mintable*, *Enumerable*.
6. Under Security pick *Ownable*.
7. Copy `lib.rs` and `Cargo.toml`.
Expand Down Expand Up @@ -157,13 +157,13 @@ cargo check
```

## Examine Openbrush Traits
Let's examine what we have inside module `Shiden34` (lib.rs) so far:
Let's examine what we have inside module `shiden34` (lib.rs) so far:
* Defined structure `Contract` for contract storage.
* Implemented constructor `new()` for `Contract` structure.
* Implemented Openbrush traits *PSP34, Metadata, Mintable, Enumberable, Ownable* for structure `Contract`.
* Overridden `mint()` method from trait *Mintable*. More about this in next section.

Each of implemented traits will enrich `Shiden34` contract with a set of methods. To examine which methods you now have available check:
Each of implemented traits will enrich `shiden34` contract with a set of methods. To examine which methods you now have available check:
* Openbrush [PSP34 trait](https://github.com/Supercolony-net/openbrush-contracts/blob/main/contracts/src/traits/psp34/psp34.rs) brings all familiar functions from ERC721 plus a few extra:
* `collection_id()`
* `balance_of()`
Expand Down

0 comments on commit bf7bbc9

Please sign in to comment.