Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
I
ink
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
parity
ink
Commits
e82d9a0d
Unverified
Commit
e82d9a0d
authored
Nov 10, 2019
by
Robin Freyler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[examples/lang] remove all lang 1.0 examples
parent
b9b9a9b3
Pipeline
#56484
failed with stages
in 1 minute and 51 seconds
Changes
48
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
0 additions
and
2383 deletions
+0
-2383
examples/lang/delegator/.cargo/config
examples/lang/delegator/.cargo/config
+0
-4
examples/lang/delegator/.gitignore
examples/lang/delegator/.gitignore
+0
-9
examples/lang/delegator/.ink/abi_gen/Cargo.toml
examples/lang/delegator/.ink/abi_gen/Cargo.toml
+0
-15
examples/lang/delegator/.ink/abi_gen/main.rs
examples/lang/delegator/.ink/abi_gen/main.rs
+0
-7
examples/lang/delegator/Cargo.toml
examples/lang/delegator/Cargo.toml
+0
-81
examples/lang/delegator/README.md
examples/lang/delegator/README.md
+0
-29
examples/lang/delegator/accumulator/Cargo.toml
examples/lang/delegator/accumulator/Cargo.toml
+0
-49
examples/lang/delegator/accumulator/src/lib.rs
examples/lang/delegator/accumulator/src/lib.rs
+0
-52
examples/lang/delegator/adder/Cargo.toml
examples/lang/delegator/adder/Cargo.toml
+0
-54
examples/lang/delegator/adder/src/lib.rs
examples/lang/delegator/adder/src/lib.rs
+0
-46
examples/lang/delegator/build-all.sh
examples/lang/delegator/build-all.sh
+0
-6
examples/lang/delegator/src/lib.rs
examples/lang/delegator/src/lib.rs
+0
-110
examples/lang/delegator/subber/Cargo.toml
examples/lang/delegator/subber/Cargo.toml
+0
-51
examples/lang/delegator/subber/src/lib.rs
examples/lang/delegator/subber/src/lib.rs
+0
-45
examples/lang/erc20/.cargo/config
examples/lang/erc20/.cargo/config
+0
-4
examples/lang/erc20/.ink/abi_gen/Cargo.toml
examples/lang/erc20/.ink/abi_gen/Cargo.toml
+0
-15
examples/lang/erc20/.ink/abi_gen/main.rs
examples/lang/erc20/.ink/abi_gen/main.rs
+0
-7
examples/lang/erc20/Cargo.toml
examples/lang/erc20/Cargo.toml
+0
-62
examples/lang/erc20/src/lib.rs
examples/lang/erc20/src/lib.rs
+0
-237
examples/lang/erc721/.cargo/config
examples/lang/erc721/.cargo/config
+0
-4
examples/lang/erc721/.ink/abi_gen/Cargo.toml
examples/lang/erc721/.ink/abi_gen/Cargo.toml
+0
-15
examples/lang/erc721/.ink/abi_gen/main.rs
examples/lang/erc721/.ink/abi_gen/main.rs
+0
-7
examples/lang/erc721/Cargo.toml
examples/lang/erc721/Cargo.toml
+0
-62
examples/lang/erc721/src/lib.rs
examples/lang/erc721/src/lib.rs
+0
-528
examples/lang/events/.cargo/config
examples/lang/events/.cargo/config
+0
-4
examples/lang/events/.gitignore
examples/lang/events/.gitignore
+0
-9
examples/lang/events/.ink/abi_gen/Cargo.toml
examples/lang/events/.ink/abi_gen/Cargo.toml
+0
-15
examples/lang/events/.ink/abi_gen/main.rs
examples/lang/events/.ink/abi_gen/main.rs
+0
-8
examples/lang/events/Cargo.toml
examples/lang/events/Cargo.toml
+0
-62
examples/lang/events/src/lib.rs
examples/lang/events/src/lib.rs
+0
-87
examples/lang/flipper/.cargo/config
examples/lang/flipper/.cargo/config
+0
-4
examples/lang/flipper/.gitignore
examples/lang/flipper/.gitignore
+0
-9
examples/lang/flipper/.ink/abi_gen/Cargo.toml
examples/lang/flipper/.ink/abi_gen/Cargo.toml
+0
-15
examples/lang/flipper/.ink/abi_gen/main.rs
examples/lang/flipper/.ink/abi_gen/main.rs
+0
-8
examples/lang/flipper/Cargo.toml
examples/lang/flipper/Cargo.toml
+0
-62
examples/lang/flipper/src/lib.rs
examples/lang/flipper/src/lib.rs
+0
-69
examples/lang/incrementer/.cargo/config
examples/lang/incrementer/.cargo/config
+0
-4
examples/lang/incrementer/.gitignore
examples/lang/incrementer/.gitignore
+0
-9
examples/lang/incrementer/.ink/abi_gen/Cargo.toml
examples/lang/incrementer/.ink/abi_gen/Cargo.toml
+0
-15
examples/lang/incrementer/.ink/abi_gen/main.rs
examples/lang/incrementer/.ink/abi_gen/main.rs
+0
-8
examples/lang/incrementer/Cargo.toml
examples/lang/incrementer/Cargo.toml
+0
-63
examples/lang/incrementer/src/lib.rs
examples/lang/incrementer/src/lib.rs
+0
-76
examples/lang/shared_vec/.cargo/config
examples/lang/shared_vec/.cargo/config
+0
-4
examples/lang/shared_vec/.gitignore
examples/lang/shared_vec/.gitignore
+0
-9
examples/lang/shared_vec/.ink/abi_gen/Cargo.toml
examples/lang/shared_vec/.ink/abi_gen/Cargo.toml
+0
-15
examples/lang/shared_vec/.ink/abi_gen/main.rs
examples/lang/shared_vec/.ink/abi_gen/main.rs
+0
-8
examples/lang/shared_vec/Cargo.toml
examples/lang/shared_vec/Cargo.toml
+0
-62
examples/lang/shared_vec/src/lib.rs
examples/lang/shared_vec/src/lib.rs
+0
-259
No files found.
examples/lang/delegator/.cargo/config
deleted
100644 → 0
View file @
b9b9a9b3
[target.wasm32-unknown-unknown]
rustflags = [
"-C", "link-args=-z stack-size=65536 --import-memory"
]
\ No newline at end of file
examples/lang/delegator/.gitignore
deleted
100644 → 0
View file @
b9b9a9b3
# 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
\ No newline at end of file
examples/lang/delegator/.ink/abi_gen/Cargo.toml
deleted
100644 → 0
View file @
b9b9a9b3
[package]
name
=
"abi-gen"
version
=
"0.1.0"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
publish
=
false
[[bin]]
name
=
"abi-gen"
path
=
"main.rs"
[dependencies]
contract
=
{
path
=
"../.."
,
package
=
"delegator"
,
features
=
["ink-generate-abi"]
}
serde
=
{
version
=
"1.0"
,
features
=
["derive"]
}
serde_json
=
"1.0"
examples/lang/delegator/.ink/abi_gen/main.rs
deleted
100644 → 0
View file @
b9b9a9b3
fn
main
()
->
Result
<
(),
std
::
io
::
Error
>
{
let
abi
=
contract
::
ink_generate_abi
();
let
contents
=
serde_json
::
to_string_pretty
(
&
abi
)
?
;
std
::
fs
::
create_dir
(
"target"
)
.ok
();
std
::
fs
::
write
(
"target/abi.json"
,
contents
)
?
;
Ok
(())
}
examples/lang/delegator/Cargo.toml
deleted
100644 → 0
View file @
b9b9a9b3
[package]
name
=
"delegator"
version
=
"0.1.0"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
[dependencies]
ink_abi
=
{
path
=
"../../../abi"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
ink_core
=
{
path
=
"../../../core"
,
default-features
=
false
}
ink_model
=
{
path
=
"../../../model"
,
default-features
=
false
}
ink_lang
=
{
path
=
"../../../lang"
,
default-features
=
false
}
scale
=
{
package
=
"parity-scale-codec"
,
version
=
"1.0"
,
default-features
=
false
,
features
=
["derive"]
}
type-metadata
=
{
git
=
"https://github.com/type-metadata/type-metadata.git"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
adder
=
{
path
=
"adder"
,
default-features
=
false
,
features
=
["ink-as-dependency"]
}
subber
=
{
path
=
"subber"
,
default-features
=
false
,
features
=
["ink-as-dependency"]
}
accumulator
=
{
path
=
"accumulator"
,
default-features
=
false
,
features
=
["ink-as-dependency"]
}
[lib]
name
=
"delegator"
crate-type
=
[
# Used for normal contract Wasm blobs.
"cdylib"
,
# Used for ABI generation.
"rlib"
,
]
[features]
default
=
["test-env"]
std
=
[
"ink_abi/std"
,
"ink_core/std"
,
"ink_model/std"
,
"ink_lang/std"
,
"scale/std"
,
"type-metadata/std"
,
"adder/std"
,
"subber/std"
,
"accumulator/std"
,
]
test-env
=
[
"std"
,
"ink_core/test-env"
,
"ink_model/test-env"
,
"ink_lang/test-env"
,
"type-metadata/std"
,
"adder/test-env"
,
"subber/test-env"
,
"accumulator/test-env"
,
]
ink-generate-abi
=
[
"std"
,
"ink_abi"
,
"type-metadata"
,
"ink_core/ink-generate-abi"
,
"adder/ink-generate-abi"
,
"subber/ink-generate-abi"
,
"accumulator/ink-generate-abi"
,
]
ink-as-dependency
=
[]
[profile.release]
panic
=
"abort"
lto
=
true
opt-level
=
"z"
overflow-checks
=
true
[workspace]
members
=
[
".ink/abi_gen"
,
"accumulator"
,
"adder"
,
"subber"
,
]
exclude
=
[
".ink"
]
examples/lang/delegator/README.md
deleted
100644 → 0
View file @
b9b9a9b3
# Delegator Smart Contract
The delegator smart contract is our showcase for executing other smart contracts on-chain.
It consists in total of 4 different smart contract:
-
Delegator (root): Delegates calls either to the Adder or Subber smart contract
-
Adder: Increases a value in the Accumulator smart contract
-
Subber: Decreases a value in the Accumulator smart contract
-
Accumulator: Owns a simple
`i32`
value that can be incremented or decremented
In order to test this bundle of smart contracts you need to do the following:
1.
Compile all dependencies of the Delegator smart contract using the
`./build-all.sh`
script.
As usual you will receive their respective Wasm blobs in their respective
`target`
folders.
1.
Go to the delegator directory (root of the example) and run
`cargo run -p abi-gen`
in order
to generate the ABI file for the Delegator smart contract.
Note: You won't need an ABI file for the other smart contracts since we won't operate on them
using the Polkadot UI.
1.
Put the Wasm blobs of Accumulator, Adder, Subber and the Delegator on the chain via
`put_code`
command.
While doing so note down their respective code hashes that you can inspect by extracting this information
out from the signalling events upon putting the code on the chain.
1.
Instantiate the Delegator smart contract given all of the code hashes and a starting value.
The Delegator smart contract will take over the work of instantiating the other smart contracts for you.
1.
Now you are able to run the operations provided by the Delegator smart contract.
Namely
`delegate`
to delegate the call to either the Adder or the Subber to either increase or decrease
the value stored in the Accumulator smart contract respectively and
`switch`
to switch the currently
delegated-to smart contract.
The initial delegated-to smart contract is the Adder.
examples/lang/delegator/accumulator/Cargo.toml
deleted
100644 → 0
View file @
b9b9a9b3
[package]
name
=
"accumulator"
version
=
"0.1.0"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
[dependencies]
ink_abi
=
{
path
=
"../../../../abi"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
ink_core
=
{
path
=
"../../../../core"
,
default-features
=
false
}
ink_model
=
{
path
=
"../../../../model"
,
default-features
=
false
}
ink_lang
=
{
path
=
"../../../../lang"
,
default-features
=
false
}
scale
=
{
package
=
"parity-scale-codec"
,
version
=
"1.0"
,
default-features
=
false
,
features
=
["derive"]
}
type-metadata
=
{
git
=
"https://github.com/type-metadata/type-metadata.git"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
[lib]
name
=
"accumulator"
crate-type
=
[
# Used for normal contract Wasm blobs.
"cdylib"
,
# Used for ABI generation.
"rlib"
,
]
[features]
default
=
["test-env"]
std
=
[
"ink_abi/std"
,
"ink_core/std"
,
"ink_model/std"
,
"ink_lang/std"
,
"scale/std"
,
"type-metadata/std"
,
]
test-env
=
[
"std"
,
"ink_core/test-env"
,
"ink_model/test-env"
,
"ink_lang/test-env"
,
"type-metadata/std"
,
]
ink-generate-abi
=
[
"std"
,
"ink_abi"
,
"type-metadata"
,
"ink_core/ink-generate-abi"
,
"ink_lang/ink-generate-abi"
,
]
ink-as-dependency
=
[]
examples/lang/delegator/accumulator/src/lib.rs
deleted
100644 → 0
View file @
b9b9a9b3
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of ink!.
//
// ink! is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ink! is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature
=
"std"
),
no_std)]
use
ink_core
::{
memory
::
format
,
storage
,
};
use
ink_lang
::
contract
;
contract!
{
#![env
=
ink_core::env::DefaultSrmlTypes]
/// Holds a simple i32 value that can be incremented and decremented.
struct
Accumulator
{
/// The current value.
value
:
storage
::
Value
<
i32
>
,
}
impl
Deploy
for
Accumulator
{
/// Initializes the value to the initial value.
fn
deploy
(
&
mut
self
,
init_value
:
i32
)
{
self
.value
.set
(
init_value
)
}
}
impl
Accumulator
{
/// Mutates the internal value.
pub
(
external
)
fn
inc
(
&
mut
self
,
by
:
i32
)
{
self
.value
+=
by
;
}
/// Returns the current state.
pub
(
external
)
fn
get
(
&
self
)
->
i32
{
*
self
.value
}
}
}
examples/lang/delegator/adder/Cargo.toml
deleted
100644 → 0
View file @
b9b9a9b3
[package]
name
=
"adder"
version
=
"0.1.0"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
[dependencies]
ink_abi
=
{
path
=
"../../../../abi"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
ink_core
=
{
path
=
"../../../../core"
,
default-features
=
false
}
ink_model
=
{
path
=
"../../../../model"
,
default-features
=
false
}
ink_lang
=
{
path
=
"../../../../lang"
,
default-features
=
false
}
scale
=
{
package
=
"parity-scale-codec"
,
version
=
"1.0"
,
default-features
=
false
,
features
=
["derive"]
}
type-metadata
=
{
git
=
"https://github.com/type-metadata/type-metadata.git"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
accumulator
=
{
path
=
"../accumulator"
,
default-features
=
false
,
features
=
["ink-as-dependency"]
}
[lib]
name
=
"adder"
crate-type
=
[
# Used for normal contract Wasm blobs.
"cdylib"
,
# Used for ABI generation.
"rlib"
,
]
[features]
default
=
["test-env"]
std
=
[
"ink_abi/std"
,
"ink_core/std"
,
"ink_model/std"
,
"ink_lang/std"
,
"scale/std"
,
"type-metadata/std"
,
"accumulator/std"
,
]
test-env
=
[
"std"
,
"ink_core/test-env"
,
"ink_model/test-env"
,
"ink_lang/test-env"
,
]
ink-generate-abi
=
[
"std"
,
"ink_abi"
,
"type-metadata"
,
"ink_core/ink-generate-abi"
,
"ink_lang/ink-generate-abi"
,
"accumulator/ink-generate-abi"
,
]
ink-as-dependency
=
[]
examples/lang/delegator/adder/src/lib.rs
deleted
100644 → 0
View file @
b9b9a9b3
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of ink!.
//
// ink! is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ink! is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature
=
"std"
),
no_std)]
use
ink_core
::{
memory
::
format
,
storage
,
};
use
ink_lang
::
contract
;
contract!
{
#![env
=
ink_core::env::DefaultSrmlTypes]
/// Increments the accumulator's value.
struct
Adder
{
/// The accumulator to store values.
accumulator
:
storage
::
Value
<
accumulator
::
Accumulator
>
,
}
impl
Deploy
for
Adder
{
fn
deploy
(
&
mut
self
,
accumulator
:
AccountId
)
{
self
.accumulator
.set
(
accumulator
::
Accumulator
::
from_account_id
(
accumulator
));
}
}
impl
Adder
{
/// Flips the current state of our smart contract.
pub
(
external
)
fn
inc
(
&
mut
self
,
by
:
i32
)
{
self
.accumulator
.inc
(
by
);
}
}
}
examples/lang/delegator/build-all.sh
deleted
100755 → 0
View file @
b9b9a9b3
#!/bin/bash
pushd
accumulator
&&
cargo contract build
&&
popd
&&
pushd
adder
&&
cargo contract build
&&
popd
&&
pushd
subber
&&
cargo contract build
&&
popd
&&
cargo contract build
examples/lang/delegator/src/lib.rs
deleted
100644 → 0
View file @
b9b9a9b3
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of ink!.
//
// ink! is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ink! is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature
=
"std"
),
no_std)]
use
ink_core
::{
memory
::
format
,
storage
,
};
use
ink_lang
::
contract
;
#[derive(Debug,
Copy,
Clone,
PartialEq,
Eq,
scale::Encode,
scale::Decode)]
#[cfg_attr(feature
=
"ink-generate-abi"
,
derive(type_metadata::Metadata))]
pub
enum
Which
{
Adder
,
Subber
,
}
impl
ink_core
::
storage
::
Flush
for
Which
{
fn
flush
(
&
mut
self
)
{}
}
contract!
{
#![env
=
ink_core::env::DefaultSrmlTypes]
/// Delegates calls to an adder or subber contract to mutate
/// a value in an accumulator contract.
///
/// In order to deploy the delegator smart contract we first
/// have to manually put the code of the accumulator, adder
/// and subber smart contracts, receive their code hashes from
/// the signalled events and put their code hash into our
/// delegator smart contract.
struct
Delegator
{
/// Says which of adder or subber is currently in use.
which
:
storage
::
Value
<
Which
>
,
/// The accumulator smart contract.
accumulator
:
storage
::
Value
<
accumulator
::
Accumulator
>
,
/// The adder smart contract.
adder
:
storage
::
Value
<
adder
::
Adder
>
,
/// The subber smart contract.
subber
:
storage
::
Value
<
subber
::
Subber
>
,
}
impl
Deploy
for
Delegator
{
/// Initializes the value to the initial value.
fn
deploy
(
&
mut
self
,
init_value
:
i32
,
accumulator_code_hash
:
Hash
,
adder_code_hash
:
Hash
,
subber_code_hash
:
Hash
,
)
{
self
.which
.set
(
Which
::
Adder
);
let
total_balance
=
env
.balance
();
let
accumulator
=
accumulator
::
Accumulator
::
new
(
accumulator_code_hash
,
init_value
)
.value
(
total_balance
/
4
)
.create
()
.expect
(
"failed at instantiating the accumulator contract"
);
self
.accumulator
.set
(
accumulator
.clone
());
self
.adder
.set
(
adder
::
Adder
::
new
(
adder_code_hash
,
accumulator
.account_id
())
.value
(
total_balance
/
4
)
.create
()
.expect
(
"failed at instantiating the adder contract"
)
);
self
.subber
.set
(
subber
::
Subber
::
new
(
subber_code_hash
,
accumulator
.account_id
())
.value
(
total_balance
/
4
)
.create
()
.expect
(
"failed at instantiating the subber contract"
)
);
}
}
impl
Delegator
{
/// Delegates the call.
pub
(
external
)
fn
delegate
(
&
mut
self
,
by
:
i32
)
{
match
&*
self
.which
{
Which
::
Adder
=>
self
.adder
.inc
(
by
),
Which
::
Subber
=>
self
.subber
.dec
(
by
),
}
}
/// Switches the delegator.
pub
(
external
)
fn
switch
(
&
mut
self
)
{
match
*
self
.which
{
Which
::
Adder
=>
{
*
self
.which
=
Which
::
Subber
;
}
Which
::
Subber
=>
{
*
self
.which
=
Which
::
Adder
;
}
}
}
}
}
examples/lang/delegator/subber/Cargo.toml
deleted
100644 → 0
View file @
b9b9a9b3
[package]
name
=
"subber"
version
=
"0.1.0"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
[dependencies]
ink_abi
=
{
path
=
"../../../../abi"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
ink_core
=
{
path
=
"../../../../core"
,
default-features
=
false
}
ink_model
=
{
path
=
"../../../../model"
,
default-features
=
false
}
ink_lang
=
{
path
=
"../../../../lang"
,
default-features
=
false
}
scale
=
{
package
=
"parity-scale-codec"
,
version
=
"1.0"
,
default-features
=
false
,
features
=
["derive"]
}
type-metadata
=
{
git
=
"https://github.com/type-metadata/type-metadata.git"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
accumulator
=
{
path
=
"../accumulator"
,
default-features
=
false
,
features
=
["ink-as-dependency"]
}
[lib]
name
=
"subber"
crate-type
=
[
# Used for normal contract Wasm blobs.
"cdylib"
,
# Used for ABI generation.
"rlib"
,
]
[features]
default
=
["test-env"]
std
=
[
"ink_abi/std"
,
"ink_core/std"
,
"ink_model/std"
,
"ink_lang/std"
,
"scale/std"
,
"type-metadata/std"
,
]
test-env
=
[
"std"
,
"ink_core/test-env"
,
"ink_model/test-env"
,
"ink_lang/test-env"
,
"type-metadata/std"
,
]
ink-generate-abi
=
[
"std"
,
"ink_abi"
,
"type-metadata"
,
"ink_core/ink-generate-abi"
,
"ink_lang/ink-generate-abi"
,
]
ink-as-dependency
=
[]
examples/lang/delegator/subber/src/lib.rs
deleted
100644 → 0
View file @
b9b9a9b3
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of ink!.
//
// ink! is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ink! is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature
=
"std"
),
no_std)]
use
ink_core
::{
memory
::
format
,
storage
,
};
use
ink_lang
::
contract
;
contract!
{
#![env
=
ink_core::env::DefaultSrmlTypes]
/// Decrements the accumulator's value.
struct
Subber
{
/// The accumulator to store values.
accumulator
:
storage
::
Value
<
accumulator
::
Accumulator
>
,
}
impl
Deploy
for
Subber
{
fn
deploy
(
&
mut
self
,
accumulator
:
AccountId
)
{
self
.accumulator
.set
(
accumulator
::
Accumulator
::
from_account_id
(
accumulator
));
}
}
impl
Subber
{
pub
(
external
)
fn
dec
(
&
mut
self
,
by
:
i32
)
{
self
.accumulator
.inc
(
-
by
);
}
}
}
examples/lang/erc20/.cargo/config
deleted
100644 → 0
View file @
b9b9a9b3
[target.wasm32-unknown-unknown]
rustflags = [
"-C", "link-args=-z stack-size=65536 --import-memory"
]
examples/lang/erc20/.ink/abi_gen/Cargo.toml
deleted
100644 → 0
View file @
b9b9a9b3
[package]
name
=
"abi-gen"
version
=
"0.1.0"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
publish
=
false
[[bin]]
name
=
"abi-gen"
path
=
"main.rs"
[dependencies]
contract
=
{
path
=
"../.."
,
package
=
"erc20"
,
features
=
["ink-generate-abi"]
}
serde
=
{
version
=
"1.0"
,
features
=
["derive"]
}
serde_json
=
"1.0"
examples/lang/erc20/.ink/abi_gen/main.rs
deleted
100644 → 0
View file @
b9b9a9b3
fn
main
()
->
Result
<
(),
std
::
io
::
Error
>
{
let
abi
=
contract
::
ink_generate_abi
();
let
contents
=
serde_json
::
to_string_pretty
(
&
abi
)
?
;
std
::
fs
::
create_dir
(
"target"
)
.ok
();
std
::
fs
::
write
(
"target/abi.json"
,
contents
)
?
;
Ok
(())
}
examples/lang/erc20/Cargo.toml
deleted
100644 → 0
View file @
b9b9a9b3
[package]
name
=
"erc20"
version
=
"0.1.0"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
[dependencies]
ink_abi
=
{
path
=
"../../../abi"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
ink_core
=
{
path
=
"../../../core"
,
default-features
=
false
}
ink_model
=
{
path
=
"../../../model"
,
default-features
=
false
}
ink_lang
=
{
path
=
"../../../lang"
,
default-features
=
false
}
scale
=
{
package
=
"parity-scale-codec"
,
version
=
"1.0"
,
default-features
=
false
,
features
=
["derive"]
}
type-metadata
=
{
git
=
"https://github.com/type-metadata/type-metadata.git"
,
default-features
=
false
,
features
=
["derive"]
,
optional
=
true
}
[lib]
name
=
"erc20"
crate-type
=
[
# Used for normal contract Wasm blobs.
"cdylib"
,
# Used for ABI generation.
"rlib"
,
]
[features]
default
=
["test-env"]
std
=
[
"ink_abi/std"
,
"ink_core/std"
,
"ink_model/std"
,
"ink_lang/std"
,
"type-metadata/std"
,
"scale/std"
,
]
test-env
=
[
"std"
,
"ink_core/test-env"
,
"ink_model/test-env"
,
"ink_lang/test-env"
,
]
ink-generate-abi
=
[
"std"
,
"ink_abi"
,
"type-metadata"
,
"ink_core/ink-generate-abi"
,
"ink_lang/ink-generate-abi"
,
]
ink-as-dependency
=
[]
[profile.release]
panic
=
"abort"
lto
=
true
opt-level
=
"z"
overflow-checks
=
true
[workspace]
members
=
[
".ink/abi_gen"
]
exclude
=
[
".ink"
]
examples/lang/erc20/src/lib.rs
deleted
100644 → 0
View file @
b9b9a9b3
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of ink!.
//
// ink! is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ink! is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature
=
"std"
),
no_std)]
use
ink_core
::{
env
::
DefaultSrmlTypes
,
memory
::
format
,
storage
,
};
use
ink_lang
::
contract
;
use
ink_model
::
EnvHandler
;
contract!
{
#![env
=
DefaultSrmlTypes]
// Event deposited when a token transfer occurs
event
Transfer
{
from
:
Option
<
AccountId
>
,
to
:
Option
<
AccountId
>
,
value
:
Balance
,
}
// Event deposited when an approval occurs
event
Approval
{
owner
:
AccountId
,
spender
:
AccountId
,
value
:
Balance
,
}
/// The storage items for a typical ERC20 token implementation.
struct
Erc20
{