@@ -101,8 +101,6 @@ mod inherent_provider {
101
101
102
102
#[ async_trait:: async_trait]
103
103
pub trait NativeTokenManagementDataSource {
104
- type Error ;
105
-
106
104
/// Retrieves total of native token transfers into the illiquid supply in the range (after_block, to_block]
107
105
async fn get_total_native_token_transfer (
108
106
& self ,
@@ -111,7 +109,7 @@ mod inherent_provider {
111
109
native_token_policy_id : PolicyId ,
112
110
native_token_asset_name : AssetName ,
113
111
illiquid_supply_address : MainchainAddress ,
114
- ) -> Result < NativeTokenAmount , Self :: Error > ;
112
+ ) -> Result < NativeTokenAmount , Box < dyn std :: error :: Error + Send + Sync > > ;
115
113
}
116
114
117
115
pub struct NativeTokenManagementInherentDataProvider {
@@ -140,7 +138,7 @@ mod inherent_provider {
140
138
pub async fn new_for_runtime_version < Block , C , E > (
141
139
version_check : fn ( RuntimeVersion ) -> bool ,
142
140
client : Arc < C > ,
143
- data_source : & ( dyn NativeTokenManagementDataSource < Error = E > + Send + Sync ) ,
141
+ data_source : & ( dyn NativeTokenManagementDataSource + Send + Sync ) ,
144
142
mc_hash : McBlockHash ,
145
143
parent_hash : <Block as BlockT >:: Hash ,
146
144
) -> Result < Self , IDPCreationError >
@@ -149,7 +147,6 @@ mod inherent_provider {
149
147
C : HeaderBackend < Block > ,
150
148
C : ProvideRuntimeApi < Block > + Send + Sync ,
151
149
C :: Api : NativeTokenManagementApi < Block > ,
152
- E : std:: error:: Error + Send + Sync + ' static ,
153
150
{
154
151
let version = client. runtime_api ( ) . version ( parent_hash) ?;
155
152
@@ -160,9 +157,9 @@ mod inherent_provider {
160
157
}
161
158
}
162
159
163
- pub async fn new < Block , C , E > (
160
+ pub async fn new < Block , C > (
164
161
client : Arc < C > ,
165
- data_source : & ( dyn NativeTokenManagementDataSource < Error = E > + Send + Sync ) ,
162
+ data_source : & ( dyn NativeTokenManagementDataSource + Send + Sync ) ,
166
163
mc_hash : McBlockHash ,
167
164
parent_hash : <Block as BlockT >:: Hash ,
168
165
) -> Result < Self , IDPCreationError >
@@ -171,7 +168,6 @@ mod inherent_provider {
171
168
C : HeaderBackend < Block > ,
172
169
C : ProvideRuntimeApi < Block > + Send + Sync ,
173
170
C :: Api : NativeTokenManagementApi < Block > ,
174
- E : std:: error:: Error + Send + Sync + ' static ,
175
171
{
176
172
let api = client. runtime_api ( ) ;
177
173
let Some ( scripts) = api. get_main_chain_scripts ( parent_hash) ? else {
@@ -192,7 +188,7 @@ mod inherent_provider {
192
188
scripts. illiquid_supply_validator_address ,
193
189
)
194
190
. await
195
- . map_err ( |err| IDPCreationError :: DataSourceError ( Box :: new ( err ) ) ) ?;
191
+ . map_err ( IDPCreationError :: DataSourceError ) ?;
196
192
197
193
let token_amount = if token_amount. 0 > 0 { Some ( token_amount) } else { None } ;
198
194
@@ -232,32 +228,25 @@ mod inherent_provider {
232
228
pub mod mock {
233
229
use crate :: NativeTokenManagementDataSource ;
234
230
use async_trait:: async_trait;
235
- use core:: marker:: PhantomData ;
236
231
use derive_new:: new;
237
232
use sidechain_domain:: * ;
238
233
use std:: collections:: HashMap ;
239
234
240
235
#[ derive( new, Default ) ]
241
- pub struct MockNativeTokenDataSource < Err > {
236
+ pub struct MockNativeTokenDataSource {
242
237
transfers : HashMap < ( Option < McBlockHash > , McBlockHash ) , NativeTokenAmount > ,
243
- _marker : PhantomData < Err > ,
244
238
}
245
239
246
240
#[ async_trait]
247
- impl < Err > NativeTokenManagementDataSource for MockNativeTokenDataSource < Err >
248
- where
249
- Err : std:: error:: Error + Send + Sync ,
250
- {
251
- type Error = Err ;
252
-
241
+ impl NativeTokenManagementDataSource for MockNativeTokenDataSource {
253
242
async fn get_total_native_token_transfer (
254
243
& self ,
255
244
after_block : Option < McBlockHash > ,
256
245
to_block : McBlockHash ,
257
246
_native_token_policy_id : PolicyId ,
258
247
_native_token_asset_name : AssetName ,
259
248
_illiquid_supply_address : MainchainAddress ,
260
- ) -> Result < NativeTokenAmount , Self :: Error > {
249
+ ) -> Result < NativeTokenAmount , Box < dyn std :: error :: Error + Send + Sync > > {
261
250
Ok ( self . transfers . get ( & ( after_block, to_block) ) . cloned ( ) . unwrap_or_default ( ) )
262
251
}
263
252
}
0 commit comments