Skip to content

Commit

Permalink
Apple trait definition fixes to 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cmichi committed Jan 18, 2024
1 parent a3d4e81 commit 92e53c4
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions versioned_docs/version-5.x/basics/trait-definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ Defined in the `base_erc20.rs` module.
```rust
#[ink::trait_definition]
pub trait BaseErc20 {
/// Creates a new ERC-20 contract and initializes it with the initial supply for the instantiator.
#[ink(constructor)]
fn new(initial_supply: Balance) -> Self;

/// Returns the total supply.
#[ink(message)]
fn total_supply(&self) -> Balance;
Expand All @@ -47,13 +43,16 @@ mod erc20 {
total_supply: Balance,
// more fields ...
}

impl BaseErc20 for Erc20 {

impl Erc20 {
/// Creates a new ERC-20 contract and initializes it with the initial supply for the instantiator.
#[ink(constructor)]
fn new(initial_supply: Balance) -> Self {
// implementation ...
}
}

impl BaseErc20 for Erc20 {
#[ink(message)]
fn total_supply(&self) -> Balance {
// implementation ...
Expand Down Expand Up @@ -106,10 +105,6 @@ type Balance = <ink::env::DefaultEnvironment as ink::env::Environment>::Balance;

#[ink::trait_definition]
pub trait Erc20 {
/// Constructs a new ERC-20 compliant smart contract using the initial supply.
#[ink(constructor)]
fn new(initial_supply: Balance) -> Self;

/// Returns the total supply of the ERC-20 smart contract.
#[ink(message)]
fn total_supply(&self) -> Balance;
Expand All @@ -128,10 +123,6 @@ mod base_erc20 {
/// We somehow cannot put the trait in the doc-test crate root due to bugs.
#[ink_lang::trait_definition]
pub trait Erc20 {
/// Constructs a new ERC-20 compliant smart contract using the initial supply.
#[ink(constructor)]
fn new(initial_supply: Balance) -> Self;

/// Returns the total supply of the ERC-20 smart contract.
#[ink(message)]
fn total_supply(&self) -> Balance;
Expand All @@ -143,12 +134,15 @@ mod base_erc20 {
// etc ..
}

impl Erc20 for BaseErc20 {
impl BaseErc20 {
/// Constructs a new ERC-20 compliant smart contract using the initial supply.
#[ink(constructor)]
fn new(initial_supply: Balance) -> Self {
Self { total_supply: initial_supply }
}
}

impl Erc20 for BaseErc20 {
/// Returns the total supply of the ERC-20 smart contract.
#[ink(message)]
fn total_supply(&self) -> Balance {
Expand Down

0 comments on commit 92e53c4

Please sign in to comment.