adder/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]
2
3pub use self::adder::{
4 Adder,
5 AdderRef,
6};
7
8use ink_lang as ink;
9
10#[ink::contract]
11mod adder {
12 use accumulator::AccumulatorRef;
13
14 /// Increments the underlying `accumulator` value.
15 #[ink(storage)]
16 pub struct Adder {
17 /// The `accumulator` to store the value.
18 accumulator: AccumulatorRef,
19 }
20
21 impl Adder {
22 /// Creates a new `adder` from the given `accumulator`.
23 #[ink(constructor)]
24 pub fn new(accumulator: AccumulatorRef) -> Self {
25 Self { accumulator }
26 }
27
28 /// Increases the `accumulator` value by some amount.
29 #[ink(message)]
30 pub fn inc(&mut self, by: i32) {
31 self.accumulator.inc(by)
32 }
33 }
34}