Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
I
ink
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
parity
ink
Commits
a3bfd946
Commit
a3bfd946
authored
Feb 19, 2019
by
Hero Bird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[pdsl] Fix another bunch of clippy and (new) compiler warnings
parent
ff2723d7
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
27 deletions
+29
-27
core/src/env/test_env.rs
core/src/env/test_env.rs
+1
-1
examples/erc20/src/lib.rs
examples/erc20/src/lib.rs
+1
-2
model/examples/erc20.rs
model/examples/erc20.rs
+1
-1
model/src/contract.rs
model/src/contract.rs
+12
-10
model/src/lib.rs
model/src/lib.rs
+1
-0
model/src/msg_handler.rs
model/src/msg_handler.rs
+12
-2
model/src/state.rs
model/src/state.rs
+1
-11
No files found.
core/src/env/test_env.rs
View file @
a3bfd946
...
...
@@ -328,7 +328,7 @@ impl TestEnv {
}
}
const
TEST_ENV_LOG_TARGET
:
&
'static
str
=
"test-env"
;
const
TEST_ENV_LOG_TARGET
:
&
str
=
"test-env"
;
impl
EnvTypes
for
TestEnv
{
type
Address
=
srml
::
Address
;
...
...
examples/erc20/src/lib.rs
View file @
a3bfd946
...
...
@@ -165,8 +165,7 @@ pub extern "C" fn deploy() {
fn
decode_params
()
->
Action
{
let
input
=
ContractEnv
::
input
();
let
action
=
Action
::
decode
(
&
mut
&
input
[
..
])
.unwrap
();
action
Action
::
decode
(
&
mut
&
input
[
..
])
.unwrap
()
}
#[no_mangle]
...
...
model/examples/erc20.rs
View file @
a3bfd946
...
...
@@ -36,7 +36,7 @@ messages! {
}
fn
instantiate
()
->
impl
Contract
{
ContractDecl
::
new
::
<
Erc20Token
>
()
ContractDecl
::
using
::
<
Erc20Token
>
()
.on_deploy
(|
env
,
init_supply
|
{
let
caller
=
env
.caller
();
env
.state.balances
[
&
caller
]
=
init_supply
;
...
...
model/src/contract.rs
View file @
a3bfd946
use
crate
::{
state
::{
ContractState
,
EmptyContractState
,
},
exec_env
::{
ExecutionEnv
,
...
...
@@ -46,7 +45,7 @@ impl<State> DeployHandler<State, NoDeployArgs> {
const
fn
init
()
->
Self
{
Self
{
args
:
PhantomData
,
deploy_fn
:
move
|
env
,
_
|
{},
deploy_fn
:
move
|
_
env
,
_
|
{},
}
}
}
...
...
@@ -130,9 +129,13 @@ where
HandlerChain
:
Copy
,
{}
/// An empty contract state.
#[derive(Copy,
Clone)]
pub
struct
EmptyContractState
;
impl
ContractDecl
<
EmptyContractState
,
NoDeployArgs
,
UnreachableMessageHandler
>
{
/// Creates a new contract declaration with the given name.
pub
const
fn
new
<
State
>
()
->
ContractDecl
<
State
,
NoDeployArgs
,
UnreachableMessageHandler
>
{
pub
const
fn
using
<
State
>
()
->
ContractDecl
<
State
,
NoDeployArgs
,
UnreachableMessageHandler
>
{
ContractDecl
{
state
:
PhantomData
,
deployer
:
DeployHandler
::
init
(),
...
...
@@ -226,7 +229,6 @@ where
use
pdsl_core
::{
storage
::{
Key
,
Allocator
,
alloc
::{
BumpAlloc
,
AllocateUsing
,
...
...
@@ -331,19 +333,19 @@ where
{
/// Calls the message encoded by the given call data.
///
/// #
Note
/// #
Panics
///
/// - If the contract has no message handler setup for the
/// message that is encoded by the given call data.
/// - If the encoded input arguments for the message do not
/// match the expected format.
fn
call_with
(
&
mut
self
,
call_data
:
CallData
)
{
let
mut
this
=
self
;
this
let
call_result
=
self
.handlers
.handle_call
(
&
mut
this
.env
,
call_data
)
.ok
()
.expect
(
"trapped during message dispatch"
);
.handle_call
(
&
mut
self
.env
,
call_data
);
if
let
Err
(
err
)
=
call_result
{
panic!
(
err
.description
())
}
}
/// Calls the given message with its expected input arguments.
...
...
model/src/lib.rs
View file @
a3bfd946
...
...
@@ -23,6 +23,7 @@ pub use crate::{
ContractState
,
},
contract
::{
EmptyContractState
,
NoDeployArgs
,
DeployHandler
,
ContractDecl
,
...
...
model/src/msg_handler.rs
View file @
a3bfd946
...
...
@@ -43,7 +43,7 @@ pub struct CallData {
raw_params
:
Vec
<
u8
>
,
}
impl
parity_codec
::
Decode
for
CallData
{
impl
Decode
for
CallData
{
fn
decode
<
I
:
parity_codec
::
Input
>
(
input
:
&
mut
I
)
->
Option
<
Self
>
{
let
selector
=
MessageHandlerSelector
::
decode
(
input
)
?
;
let
mut
param_buf
=
Vec
::
new
();
...
...
@@ -230,6 +230,16 @@ pub enum Error {
InvalidArguments
,
}
impl
Error
{
/// Returns a short description of the error.
pub
fn
description
(
&
self
)
->
&
'static
str
{
match
self
{
Error
::
InvalidFunctionSelector
=>
"encountered invalid message selector"
,
Error
::
InvalidArguments
=>
"encountered invalid arguments for selected message"
}
}
}
/// Results of message handling operations.
pub
type
Result
<
T
>
=
CoreResult
<
T
,
Error
>
;
...
...
@@ -255,7 +265,7 @@ pub struct UnreachableMessageHandler;
impl
<
State
>
HandleCall
<
State
>
for
UnreachableMessageHandler
{
type
Output
=
();
fn
handle_call
(
&
self
,
_
env
:
&
mut
ExecutionEnv
<
State
>
,
data
:
CallData
)
->
Result
<
Self
::
Output
>
{
fn
handle_call
(
&
self
,
_
env
:
&
mut
ExecutionEnv
<
State
>
,
_
data
:
CallData
)
->
Result
<
Self
::
Output
>
{
Err
(
Error
::
InvalidFunctionSelector
)
}
}
...
...
model/src/state.rs
View file @
a3bfd946
use
pdsl_core
::{
storage
::{
Flush
,
alloc
::{
AllocateUsing
,
Initialize
,
},
alloc
::
AllocateUsing
,
},
};
...
...
@@ -69,10 +66,3 @@ macro_rules! state {
}
};
}
use
crate
as
pdsl_model
;
// TODO: Fix this to being not required!
state!
{
/// An empty contract state.
pub
struct
EmptyContractState
{}
}
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