@@ -81,8 +81,6 @@ pub mod module {
81
81
82
82
#[ pallet:: config]
83
83
pub trait Config : frame_system:: Config {
84
- type Event : From < Event < Self > > + IsType < <Self as frame_system:: Config >:: Event > ;
85
-
86
84
type MultiCurrency : TransferAll < Self :: AccountId >
87
85
+ MultiCurrencyExtended < Self :: AccountId >
88
86
+ MultiLockableCurrency < Self :: AccountId >
@@ -109,36 +107,6 @@ pub mod module {
109
107
DepositFailed ,
110
108
}
111
109
112
- #[ pallet:: event]
113
- #[ pallet:: generate_deposit( pub ( crate ) fn deposit_event) ]
114
- pub enum Event < T : Config > {
115
- /// Currency transfer success.
116
- Transferred {
117
- currency_id : CurrencyIdOf < T > ,
118
- from : T :: AccountId ,
119
- to : T :: AccountId ,
120
- amount : BalanceOf < T > ,
121
- } ,
122
- /// Update balance success.
123
- BalanceUpdated {
124
- currency_id : CurrencyIdOf < T > ,
125
- who : T :: AccountId ,
126
- amount : AmountOf < T > ,
127
- } ,
128
- /// Deposit success.
129
- Deposited {
130
- currency_id : CurrencyIdOf < T > ,
131
- who : T :: AccountId ,
132
- amount : BalanceOf < T > ,
133
- } ,
134
- /// Withdraw success.
135
- Withdrawn {
136
- currency_id : CurrencyIdOf < T > ,
137
- who : T :: AccountId ,
138
- amount : BalanceOf < T > ,
139
- } ,
140
- }
141
-
142
110
#[ pallet:: pallet]
143
111
pub struct Pallet < T > ( _ ) ;
144
112
@@ -160,8 +128,7 @@ pub mod module {
160
128
) -> DispatchResult {
161
129
let from = ensure_signed ( origin) ?;
162
130
let to = T :: Lookup :: lookup ( dest) ?;
163
- <Self as MultiCurrency < T :: AccountId > >:: transfer ( currency_id, & from, & to, amount) ?;
164
- Ok ( ( ) )
131
+ <Self as MultiCurrency < T :: AccountId > >:: transfer ( currency_id, & from, & to, amount)
165
132
}
166
133
167
134
/// Transfer some native currency to another account.
@@ -176,15 +143,7 @@ pub mod module {
176
143
) -> DispatchResult {
177
144
let from = ensure_signed ( origin) ?;
178
145
let to = T :: Lookup :: lookup ( dest) ?;
179
- T :: NativeCurrency :: transfer ( & from, & to, amount) ?;
180
-
181
- Self :: deposit_event ( Event :: Transferred {
182
- currency_id : T :: GetNativeCurrencyId :: get ( ) ,
183
- from,
184
- to,
185
- amount,
186
- } ) ;
187
- Ok ( ( ) )
146
+ T :: NativeCurrency :: transfer ( & from, & to, amount)
188
147
}
189
148
190
149
/// update amount of account `who` under `currency_id`.
@@ -199,8 +158,7 @@ pub mod module {
199
158
) -> DispatchResult {
200
159
ensure_root ( origin) ?;
201
160
let dest = T :: Lookup :: lookup ( who) ?;
202
- <Self as MultiCurrencyExtended < T :: AccountId > >:: update_balance ( currency_id, & dest, amount) ?;
203
- Ok ( ( ) )
161
+ <Self as MultiCurrencyExtended < T :: AccountId > >:: update_balance ( currency_id, & dest, amount)
204
162
}
205
163
}
206
164
}
@@ -259,51 +217,32 @@ impl<T: Config> MultiCurrency<T::AccountId> for Pallet<T> {
259
217
return Ok ( ( ) ) ;
260
218
}
261
219
if currency_id == T :: GetNativeCurrencyId :: get ( ) {
262
- T :: NativeCurrency :: transfer ( from, to, amount) ? ;
220
+ T :: NativeCurrency :: transfer ( from, to, amount)
263
221
} else {
264
- T :: MultiCurrency :: transfer ( currency_id, from, to, amount) ? ;
222
+ T :: MultiCurrency :: transfer ( currency_id, from, to, amount)
265
223
}
266
- Self :: deposit_event ( Event :: Transferred {
267
- currency_id,
268
- from : from. clone ( ) ,
269
- to : to. clone ( ) ,
270
- amount,
271
- } ) ;
272
- Ok ( ( ) )
273
224
}
274
225
275
226
fn deposit ( currency_id : Self :: CurrencyId , who : & T :: AccountId , amount : Self :: Balance ) -> DispatchResult {
276
227
if amount. is_zero ( ) {
277
228
return Ok ( ( ) ) ;
278
229
}
279
230
if currency_id == T :: GetNativeCurrencyId :: get ( ) {
280
- T :: NativeCurrency :: deposit ( who, amount) ? ;
231
+ T :: NativeCurrency :: deposit ( who, amount)
281
232
} else {
282
- T :: MultiCurrency :: deposit ( currency_id, who, amount) ? ;
233
+ T :: MultiCurrency :: deposit ( currency_id, who, amount)
283
234
}
284
- Self :: deposit_event ( Event :: Deposited {
285
- currency_id,
286
- who : who. clone ( ) ,
287
- amount,
288
- } ) ;
289
- Ok ( ( ) )
290
235
}
291
236
292
237
fn withdraw ( currency_id : Self :: CurrencyId , who : & T :: AccountId , amount : Self :: Balance ) -> DispatchResult {
293
238
if amount. is_zero ( ) {
294
239
return Ok ( ( ) ) ;
295
240
}
296
241
if currency_id == T :: GetNativeCurrencyId :: get ( ) {
297
- T :: NativeCurrency :: withdraw ( who, amount) ? ;
242
+ T :: NativeCurrency :: withdraw ( who, amount)
298
243
} else {
299
- T :: MultiCurrency :: withdraw ( currency_id, who, amount) ? ;
244
+ T :: MultiCurrency :: withdraw ( currency_id, who, amount)
300
245
}
301
- Self :: deposit_event ( Event :: Withdrawn {
302
- currency_id,
303
- who : who. clone ( ) ,
304
- amount,
305
- } ) ;
306
- Ok ( ( ) )
307
246
}
308
247
309
248
fn can_slash ( currency_id : Self :: CurrencyId , who : & T :: AccountId , amount : Self :: Balance ) -> bool {
@@ -328,16 +267,10 @@ impl<T: Config> MultiCurrencyExtended<T::AccountId> for Pallet<T> {
328
267
329
268
fn update_balance ( currency_id : Self :: CurrencyId , who : & T :: AccountId , by_amount : Self :: Amount ) -> DispatchResult {
330
269
if currency_id == T :: GetNativeCurrencyId :: get ( ) {
331
- T :: NativeCurrency :: update_balance ( who, by_amount) ? ;
270
+ T :: NativeCurrency :: update_balance ( who, by_amount)
332
271
} else {
333
- T :: MultiCurrency :: update_balance ( currency_id, who, by_amount) ? ;
272
+ T :: MultiCurrency :: update_balance ( currency_id, who, by_amount)
334
273
}
335
- Self :: deposit_event ( Event :: BalanceUpdated {
336
- currency_id,
337
- who : who. clone ( ) ,
338
- amount : by_amount,
339
- } ) ;
340
- Ok ( ( ) )
341
274
}
342
275
}
343
276
@@ -608,7 +541,6 @@ where
608
541
let actual_deposit = deposit_result. peek ( ) ;
609
542
ensure ! ( actual_deposit == amount, Error :: <T >:: DepositFailed ) ;
610
543
}
611
-
612
544
Ok ( ( ) )
613
545
}
614
546
0 commit comments