-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66c46a0
commit e1111a3
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Ignore build artifacts from the local tests sub-crate. | ||
/target/ | ||
|
||
# Ignore backup files creates by cargo fmt. | ||
**/*.rs.bk | ||
|
||
# Remove Cargo.lock when creating an executable, leave it for libraries | ||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "lazytest" | ||
version = "0.1.0" | ||
authors = ["[your_name] <[your_email]>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ink = { version = "4.2", default-features = false } | ||
|
||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } | ||
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } | ||
|
||
[dev-dependencies] | ||
ink_e2e = "4.2" | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"ink/std", | ||
"scale/std", | ||
"scale-info/std", | ||
] | ||
ink-as-dependency = [] | ||
e2e-tests = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
#[ink::contract] | ||
mod lazytest { | ||
use ink::storage::{Lazy, traits::ManualKey}; | ||
|
||
/// Defines the storage of your contract. | ||
/// Add new fields to the below struct in order | ||
/// to add new static storage fields to your contract. | ||
#[derive(Default)] | ||
#[ink(storage)] | ||
pub struct Lazytest { | ||
/// Stores a single `bool` value on the storage. | ||
value1: Lazy<u32>, | ||
value2: Lazy<u32, ManualKey<123>>, | ||
} | ||
|
||
impl Lazytest { | ||
/// Constructor that initializes the `bool` value to the given `init_value`. | ||
#[ink(constructor)] | ||
pub fn new() -> Self { | ||
Lazytest::default() | ||
} | ||
|
||
|
||
/// A message that can be called on instantiated contracts. | ||
/// This one flips the value of the stored `bool` from `true` | ||
/// to `false` and vice versa. | ||
#[ink(message)] | ||
pub fn set_1(&mut self, a: u32) { | ||
self.value1.set(&a); | ||
} | ||
|
||
/// Simply returns the current value of our `bool`. | ||
#[ink(message)] | ||
pub fn get_1(&self) -> Option<u32> { | ||
self.value1.get() | ||
} | ||
|
||
#[ink(message)] | ||
pub fn set_2(&mut self, a: u32) { | ||
self.value2.set(&a); | ||
} | ||
|
||
/// Simply returns the current value of our `bool`. | ||
#[ink(message)] | ||
pub fn get_2(&self) -> Option<u32> { | ||
self.value2.get() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters