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
b61ad390
Commit
b61ad390
authored
Feb 13, 2019
by
Hero Bird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[pdsl_model] Add interface stubs for Contract and ContractInstance
parent
9ae6547a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
model/src/contract.rs
model/src/contract.rs
+60
-0
No files found.
model/src/contract.rs
View file @
b61ad390
...
...
@@ -210,4 +210,64 @@ where
{
self
.append_msg_handler
(
MessageHandlerMut
::
from_raw
(
handler
))
}
pub
const
fn
instantiate
(
self
)
->
ContractInstance
<
State
,
DeployArgs
,
HandlerChain
>
{
ContractInstance
{
decl
:
self
}
}
}
pub
trait
Contract
{
/// Deploys the contract state.
///
/// Should be performed exactly once during contract lifetime.
/// Consumes the contract since nothing should be done afterwards.
fn
deploy
(
self
);
/// Dispatches the call input to a pre defined
/// contract message and runs its handler.
///
/// Consumes self since it should be the default
/// action after instantiation.
///
/// # Panics
///
/// Panics (Wasm: traps) if the call input was invalid.
/// The call input is invalid if there was no matching
/// function selector found or if the data for a given
/// selected function was not decodable.
fn
dispatch
(
self
);
}
pub
struct
ContractInstance
<
State
,
DeployArgs
,
HandlerChain
>
{
decl
:
ContractDecl
<
State
,
DeployArgs
,
HandlerChain
>
,
}
impl
<
State
,
DeployArgs
,
HandlerChain
>
Contract
for
ContractInstance
<
State
,
DeployArgs
,
HandlerChain
>
{
fn
deploy
(
self
)
{
// Deploys the contract state.
//
// Should be performed exactly once during contract lifetime.
// Consumes the contract since nothing should be done afterwards.
unimplemented!
()
}
fn
dispatch
(
self
)
{
// Dispatches the given input to a pre defined
// contract message and runs its handler.
//
// Consumes self since it should be the default
// action after instantiation.
//
// Internally calls the associated call<Msg>.
unimplemented!
()
}
}
impl
<
State
,
DeployArgs
,
HandlerChain
>
ContractInstance
<
State
,
DeployArgs
,
HandlerChain
>
{
fn
call
<
Msg
>
(
self
,
_
args
:
<
Msg
as
Message
>
::
Input
)
where
Msg
:
Message
,
{
unimplemented!
()
}
}
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