@@ -20,7 +20,6 @@ use crate::{
20
20
Env ,
21
21
EnvStorage ,
22
22
EnvTypes ,
23
- EnvReturnData ,
24
23
} ,
25
24
memory:: vec:: Vec ,
26
25
storage:: Key ,
@@ -73,27 +72,12 @@ impl EnvStorage for SrmlEnvStorage {
73
72
}
74
73
}
75
74
76
- /// Wrapped access to return data.
77
- /// get() or get_raw Must be used right after ReturnData is returned.
78
- pub struct SrmlReturnData ;
79
-
80
- impl EnvReturnData for SrmlReturnData
81
- {
82
- fn get < U : Decode > ( self ) -> U {
83
- U :: decode ( & mut & read_scratch_buffer ( ) [ ..] ) . unwrap ( )
84
- }
85
-
86
- fn get_raw ( self ) -> Vec < u8 > {
87
- read_scratch_buffer ( )
88
- }
89
- }
90
-
91
75
/// The SRML contracts environment.
92
76
pub struct SrmlEnv < T >
93
77
where
94
78
T : EnvTypes ,
95
79
{
96
- marker : PhantomData < fn ( ) -> T > ,
80
+ marker : PhantomData < fn ( ) -> T > ,
97
81
}
98
82
99
83
impl < T > EnvTypes for SrmlEnv < T >
@@ -129,8 +113,6 @@ where
129
113
T : EnvTypes ,
130
114
{
131
115
132
- type ReturnData = SrmlReturnData ;
133
-
134
116
fn input ( ) -> Vec < u8 > {
135
117
read_scratch_buffer ( )
136
118
}
@@ -165,13 +147,33 @@ where
165
147
)
166
148
}
167
149
}
150
+ fn call_invoke (
151
+ callee : <Self as EnvTypes >:: AccountId ,
152
+ gas : u64 ,
153
+ value : <Self as EnvTypes >:: Balance ,
154
+ input_data : & [ u8 ] ,
155
+ ) {
156
+ let callee = callee. encode ( ) ;
157
+ let value = value. encode ( ) ;
158
+ unsafe {
159
+ sys:: ext_call (
160
+ callee. as_ptr ( ) as u32 ,
161
+ callee. len ( ) as u32 ,
162
+ gas,
163
+ value. as_ptr ( ) as u32 ,
164
+ value. len ( ) as u32 ,
165
+ input_data. as_ptr ( ) as u32 ,
166
+ input_data. len ( ) as u32
167
+ ) ;
168
+ }
169
+ }
168
170
169
- fn call (
171
+ fn call_evaluate < U : Decode > (
170
172
callee : <Self as EnvTypes >:: AccountId ,
171
173
gas : u64 ,
172
174
value : <Self as EnvTypes >:: Balance ,
173
175
input_data : & [ u8 ] ,
174
- ) -> Option < Self :: ReturnData > {
176
+ ) -> Option < U > {
175
177
let callee = callee. encode ( ) ;
176
178
let value = value. encode ( ) ;
177
179
unsafe {
@@ -185,7 +187,7 @@ where
185
187
input_data. len ( ) as u32
186
188
) ;
187
189
if success == 0 {
188
- Some ( Self :: ReturnData { } )
190
+ Some ( U :: decode ( & mut & read_scratch_buffer ( ) [ .. ] ) . unwrap ( ) )
189
191
} else {
190
192
None
191
193
}
0 commit comments