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
Hide 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 {
...
@@ -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
{
impl
EnvTypes
for
TestEnv
{
type
Address
=
srml
::
Address
;
type
Address
=
srml
::
Address
;
...
...
examples/erc20/src/lib.rs
View file @
a3bfd946
...
@@ -165,8 +165,7 @@ pub extern "C" fn deploy() {
...
@@ -165,8 +165,7 @@ pub extern "C" fn deploy() {
fn
decode_params
()
->
Action
{
fn
decode_params
()
->
Action
{
let
input
=
ContractEnv
::
input
();
let
input
=
ContractEnv
::
input
();
let
action
=
Action
::
decode
(
&
mut
&
input
[
..
])
.unwrap
();
Action
::
decode
(
&
mut
&
input
[
..
])
.unwrap
()
action
}
}
#[no_mangle]
#[no_mangle]
...
...
model/examples/erc20.rs
View file @
a3bfd946
...
@@ -36,7 +36,7 @@ messages! {
...
@@ -36,7 +36,7 @@ messages! {
}
}
fn
instantiate
()
->
impl
Contract
{
fn
instantiate
()
->
impl
Contract
{
ContractDecl
::
new
::
<
Erc20Token
>
()
ContractDecl
::
using
::
<
Erc20Token
>
()
.on_deploy
(|
env
,
init_supply
|
{
.on_deploy
(|
env
,
init_supply
|
{
let
caller
=
env
.caller
();
let
caller
=
env
.caller
();
env
.state.balances
[
&
caller
]
=
init_supply
;
env
.state.balances
[
&
caller
]
=
init_supply
;
...
...
model/src/contract.rs
View file @
a3bfd946
use
crate
::{
use
crate
::{
state
::{
state
::{
ContractState
,
ContractState
,
EmptyContractState
,
},
},
exec_env
::{
exec_env
::{
ExecutionEnv
,
ExecutionEnv
,
...
@@ -46,7 +45,7 @@ impl<State> DeployHandler<State, NoDeployArgs> {
...
@@ -46,7 +45,7 @@ impl<State> DeployHandler<State, NoDeployArgs> {
const
fn
init
()
->
Self
{
const
fn
init
()
->
Self
{
Self
{
Self
{
args
:
PhantomData
,
args
:
PhantomData
,
deploy_fn
:
move
|
env
,
_
|
{},
deploy_fn
:
move
|
_
env
,
_
|
{},
}
}
}
}
}
}
...
@@ -130,9 +129,13 @@ where
...
@@ -130,9 +129,13 @@ where
HandlerChain
:
Copy
,
HandlerChain
:
Copy
,
{}
{}
/// An empty contract state.
#[derive(Copy,
Clone)]
pub
struct
EmptyContractState
;
impl
ContractDecl
<
EmptyContractState
,
NoDeployArgs
,
UnreachableMessageHandler
>
{
impl
ContractDecl
<
EmptyContractState
,
NoDeployArgs
,
UnreachableMessageHandler
>
{
/// Creates a new contract declaration with the given name.
/// 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
{
ContractDecl
{
state
:
PhantomData
,
state
:
PhantomData
,
deployer
:
DeployHandler
::
init
(),
deployer
:
DeployHandler
::
init
(),
...
@@ -226,7 +229,6 @@ where
...
@@ -226,7 +229,6 @@ where
use
pdsl_core
::{
use
pdsl_core
::{
storage
::{
storage
::{
Key
,
Key
,
Allocator
,
alloc
::{
alloc
::{
BumpAlloc
,
BumpAlloc
,
AllocateUsing
,
AllocateUsing
,
...
@@ -331,19 +333,19 @@ where
...
@@ -331,19 +333,19 @@ where
{
{
/// Calls the message encoded by the given call data.
/// Calls the message encoded by the given call data.
///
///
/// #
Note
/// #
Panics
///
///
/// - If the contract has no message handler setup for the
/// - If the contract has no message handler setup for the
/// message that is encoded by the given call data.
/// message that is encoded by the given call data.
/// - If the encoded input arguments for the message do not
/// - If the encoded input arguments for the message do not
/// match the expected format.
/// match the expected format.
fn
call_with
(
&
mut
self
,
call_data
:
CallData
)
{
fn
call_with
(
&
mut
self
,
call_data
:
CallData
)
{
let
mut
this
=
self
;
let
call_result
=
self
this
.handlers
.handlers
.handle_call
(
&
mut
this
.env
,
call_data
)
.handle_call
(
&
mut
self
.env
,
call_data
);
.ok
()
if
let
Err
(
err
)
=
call_result
{
.expect
(
"trapped during message dispatch"
);
panic!
(
err
.description
())
}
}
}
/// Calls the given message with its expected input arguments.
/// Calls the given message with its expected input arguments.
...
...
model/src/lib.rs
View file @
a3bfd946
...
@@ -23,6 +23,7 @@ pub use crate::{
...
@@ -23,6 +23,7 @@ pub use crate::{
ContractState
,
ContractState
,
},
},
contract
::{
contract
::{
EmptyContractState
,
NoDeployArgs
,
NoDeployArgs
,
DeployHandler
,
DeployHandler
,
ContractDecl
,
ContractDecl
,
...
...
model/src/msg_handler.rs
View file @
a3bfd946
...
@@ -43,7 +43,7 @@ pub struct CallData {
...
@@ -43,7 +43,7 @@ pub struct CallData {
raw_params
:
Vec
<
u8
>
,
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
>
{
fn
decode
<
I
:
parity_codec
::
Input
>
(
input
:
&
mut
I
)
->
Option
<
Self
>
{
let
selector
=
MessageHandlerSelector
::
decode
(
input
)
?
;
let
selector
=
MessageHandlerSelector
::
decode
(
input
)
?
;
let
mut
param_buf
=
Vec
::
new
();
let
mut
param_buf
=
Vec
::
new
();
...
@@ -230,6 +230,16 @@ pub enum Error {
...
@@ -230,6 +230,16 @@ pub enum Error {
InvalidArguments
,
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.
/// Results of message handling operations.
pub
type
Result
<
T
>
=
CoreResult
<
T
,
Error
>
;
pub
type
Result
<
T
>
=
CoreResult
<
T
,
Error
>
;
...
@@ -255,7 +265,7 @@ pub struct UnreachableMessageHandler;
...
@@ -255,7 +265,7 @@ pub struct UnreachableMessageHandler;
impl
<
State
>
HandleCall
<
State
>
for
UnreachableMessageHandler
{
impl
<
State
>
HandleCall
<
State
>
for
UnreachableMessageHandler
{
type
Output
=
();
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
)
Err
(
Error
::
InvalidFunctionSelector
)
}
}
}
}
...
...
model/src/state.rs
View file @
a3bfd946
use
pdsl_core
::{
use
pdsl_core
::{
storage
::{
storage
::{
Flush
,
Flush
,
alloc
::{
alloc
::
AllocateUsing
,
AllocateUsing
,
Initialize
,
},
},
},
};
};
...
@@ -69,10 +66,3 @@ macro_rules! state {
...
@@ -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