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
3497a1d7
Commit
3497a1d7
authored
Jan 24, 2019
by
Hero Bird
Browse files
[examples/erc20] Remove lazy_static and spin dependencies
parent
fb6a8ce9
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/erc20/Cargo.toml
View file @
3497a1d7
...
...
@@ -8,9 +8,6 @@ edition = "2018"
pdsl_core
=
{
path
=
"../../pdsl_core"
}
parity-codec
=
{
version
=
"2.2"
,
default-features
=
false
,
features
=
["derive"]
}
lazy_static
=
{
version
=
"1.2"
,
features
=
["spin_no_std"]
}
spin
=
{
version
=
"0.4"
,
default-features
=
false
}
[lib]
name
=
"erc20_token"
crate-type
=
["cdylib"]
...
...
examples/erc20/src/lib.rs
View file @
3497a1d7
...
...
@@ -10,9 +10,6 @@ use pdsl_core::{
};
use
parity_codec
::{
Encode
,
Decode
};
use
lazy_static
::
lazy_static
;
use
spin
::
Mutex
;
type
Balance
=
u64
;
/// Returns the zero address.
...
...
@@ -116,26 +113,6 @@ impl Erc20Token {
}
}
impl
Default
for
Erc20Token
{
fn
default
()
->
Self
{
unsafe
{
Erc20Token
::
new_using_alloc
(
&
mut
*
STORAGE_ALLOC
.lock
()
)
}
}
}
lazy_static!
{
pub
(
crate
)
static
ref
STORAGE_ALLOC
:
Mutex
<
ForwardAlloc
>
=
{
Mutex
::
new
(
unsafe
{
ForwardAlloc
::
from_raw_parts
(
Key
([
0x0
;
32
])
)
})
};
}
/// Erc20Token API.
#[derive(Encode,
Decode)]
enum
Action
{
...
...
@@ -166,8 +143,10 @@ pub extern "C" fn call() {
let
input
=
ContractEnv
::
input
();
let
action
=
Action
::
decode
(
&
mut
&
input
[
..
])
.unwrap
();
let
mut
erc20token
=
crate
::
Erc20Token
::
default
();
let
mut
alloc
=
unsafe
{
ForwardAlloc
::
from_raw_parts
(
Key
([
0x0
;
32
]))
};
let
mut
erc20token
=
unsafe
{
Erc20Token
::
new_using_alloc
(
&
mut
alloc
)
};
match
action
{
Action
::
TotalSupply
=>
{
ret
(
erc20token
.total_supply
())
...
...
Write
Preview
Markdown
is supported
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