Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
ink
Commits
61c89eb8
Commit
61c89eb8
authored
Feb 18, 2019
by
Hero Bird
Browse files
[examples/fleet_inc] Add fleet_inc example
parent
5d7bc08f
Changes
5
Hide whitespace changes
Inline
Side-by-side
examples/fleet_inc/.cargo/config
0 → 100644
View file @
61c89eb8
[target.wasm32-unknown-unknown]
rustflags = [
"-C", "link-args=-z stack-size=65536 --import-memory"
]
examples/fleet_inc/Cargo.toml
0 → 100644
View file @
61c89eb8
[package]
name
=
"fleet-inc"
version
=
"0.1.0"
authors
=
[
"Parity Technologies <admin@parity.io>"
]
edition
=
"2018"
[dependencies]
pdsl_core
=
{
path
=
"../../core"
}
pdsl_model
=
{
path
=
"../../model"
}
parity-codec
=
{
version
=
"2.2"
,
default-features
=
false
,
features
=
["derive"]
}
[lib]
name
=
"fleet_inc"
crate-type
=
["cdylib"]
[features]
default
=
[]
test-env
=
[
"pdsl_core/test-env"
,
"pdsl_model/test-env"
,
]
[profile.release]
panic
=
"abort"
lto
=
true
opt-level
=
"z"
examples/fleet_inc/build.sh
0 → 100755
View file @
61c89eb8
#!/bin/bash
# The wasm-build executable that is used to tree-shake the wasm binary
# resulting from the cargo build in the first step expects to find it
# under target/release/wasm32-unknown-unknown/ in the cwd.
cargo +nightly build
--release
--target
=
wasm32-unknown-unknown
--verbose
wasm-build target fleet_inc
--target-runtime
=
substrate
--final
=
fleet_inc
--save-raw
=
./target/fleet_inc-deployed.wasm
--target
wasm32-unknown-unknown
examples/fleet_inc/rust-toolchain
0 → 100644
View file @
61c89eb8
nightly-2019-01-26
examples/fleet_inc/src/lib.rs
0 → 100644
View file @
61c89eb8
#![no_std]
#![feature(const_str_as_bytes)]
use
pdsl_model
::{
ContractDecl
,
Contract
,
state
,
messages
,
};
use
pdsl_core
::
storage
;
state!
{
/// A simple contract having just one value that can be incremented and returned.
struct
Adder
{
/// The simple value on the contract storage.
val
:
storage
::
Value
<
u32
>
}
}
messages!
{
/// Increases the storage value by the given amount.
0
=>
Inc
(
by
:
u32
);
/// Returns the storage value.
1
=>
Get
()
->
u32
;
}
fn
instantiate
()
->
impl
Contract
{
ContractDecl
::
new
::
<
Adder
>
()
.on_deploy
(|
env
,
init_val
|
{
env
.state.val
.set
(
init_val
)
})
.on_msg_mut
::
<
Inc
>
(|
env
,
by
|
{
env
.state.val
+=
by
})
.on_msg
::
<
Get
>
(|
env
,
_
|
{
*
env
.state.val
.get
()
})
.instantiate
()
}
#[no_mangle]
fn
deploy
()
{
instantiate
()
.deploy
()
}
#[no_mangle]
fn
call
()
{
instantiate
()
.dispatch
()
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment