Skip to content

Commit efb802a

Browse files
Merge pull request #69 from thashimoto1998/master
rm transfer_to_celer_wallet and fix name
2 parents b355ceb + 3bcc12a commit efb802a

File tree

10 files changed

+382
-546
lines changed

10 files changed

+382
-546
lines changed

pallets/celer-pay/src/celer_wallet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{Module, BalanceOf, Error, Wallets, RawEvent};
1+
use super::{Module as CelerPayModule, BalanceOf, Error, Wallets, RawEvent};
22
use crate::traits::Trait;
33
use codec::{Decode, Encode};
44
use frame_support::traits::{Currency, ExistenceRequirement};
@@ -36,7 +36,7 @@ impl<T: Trait> CelerWallet<T> {
3636
update_balance::<T>(caller, wallet_id.clone(), msg_value.clone())?;
3737

3838
// Emit DepositToWallet event
39-
Module::<T>::deposit_event(RawEvent::DepositToWallet(
39+
CelerPayModule::<T>::deposit_event(RawEvent::DepositToWallet(
4040
wallet_id,
4141
msg_value
4242
));
@@ -55,7 +55,7 @@ fn update_balance<T: Trait>(
5555
None => Err(Error::<T>::WalletNotExist)?,
5656
};
5757

58-
let celer_wallet_account = Module::<T>::get_celer_wallet_id();
58+
let celer_wallet_account = CelerPayModule::<T>::get_celer_wallet_id();
5959

6060
let new_amount = w.balance.checked_add(&msg_value).ok_or(Error::<T>::OverFlow)?;
6161

pallets/celer-pay/src/ledger_operation.rs

Lines changed: 144 additions & 141 deletions
Large diffs are not rendered by default.

pallets/celer-pay/src/lib.rs

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -676,34 +676,6 @@ decl_module! {
676676
Ok(())
677677
}
678678

679-
/// Transfer to native token from one address to a wallet in CelerWallet Module.
680-
///
681-
/// Parameters:
682-
/// `from`: the address which you want to transfer native token from
683-
/// `wallet_id`: Id of the wallet you want to deposit funds into
684-
/// `amount`: amount of funds to be transfered
685-
///
686-
/// # <weight>
687-
/// ## Weight
688-
/// - Complexity: `O(1)`
689-
/// - DB:
690-
/// - 1 storage reads `Wallets`
691-
/// - 1 storage mutation `Wallets`
692-
/// - 1 storage reads `Balances`
693-
/// - 1 storage mutation `Balances`
694-
/// - 2 storage reads `Allowed`
695-
/// # </weight>
696-
#[weight = 100_000_000 + T::DbWeight::get().reads_writes(4, 2)]
697-
fn transfer_to_celer_wallet(
698-
origin,
699-
from: T::AccountId,
700-
wallet_id: T::Hash,
701-
amount: BalanceOf<T>
702-
) -> DispatchResult {
703-
Pool::<T>::transfer_to_celer_wallet(origin, from, wallet_id, amount)?;
704-
Ok(())
705-
}
706-
707679
/// Increase the amount of native token that an owner allowed to a spender.
708680
///
709681
/// Parameters:
@@ -843,7 +815,7 @@ decl_module! {
843815
));
844816
}
845817

846-
/// Emit channel settle open time
818+
/// Emit channel confirm settle open time
847819
#[weight = 10_000]
848820
fn emit_settle_finalized_time(_origin, channel_id: T::Hash) {
849821
let c = match Self::channel_map(channel_id) {
@@ -1687,12 +1659,12 @@ impl<T: Trait> Module<T> {
16871659
encoded: &[u8],
16881660
signers: Vec<T::AccountId>,
16891661
) -> Result<(), DispatchError> {
1690-
let signature1 = &signatures[0];
1691-
let signature2 = &signatures[1];
1662+
let signature_0 = &signatures[0];
1663+
let signature_1 = &signatures[1];
16921664
ensure!(
1693-
(signature1.verify(encoded, &signers[0]) && signature2.verify(encoded, &signers[1]))
1694-
|| (signature1.verify(encoded, &signers[1])
1695-
&& signature2.verify(encoded, &signers[0])),
1665+
(signature_0.verify(encoded, &signers[0]) && signature_1.verify(encoded, &signers[1]))
1666+
|| (signature_0.verify(encoded, &signers[1])
1667+
&& signature_1.verify(encoded, &signers[0])),
16961668
"Check co-sigs failed"
16971669
);
16981670

pallets/celer-pay/src/migration.rs

Lines changed: 64 additions & 63 deletions
Large diffs are not rendered by default.

pallets/celer-pay/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl_outer_event! {
3939
impl_outer_dispatch! {
4040
pub enum Call for TestRuntime where origin: Origin {
4141
frame_system::System,
42-
celer_pay::CelerModule,
42+
celer_pay::CelerPayModule,
4343
mock_boolean_condition::MockBooleanCondition,
4444
}
4545
}
@@ -116,7 +116,7 @@ impl Trait for TestRuntime {
116116
type Call = Call;
117117
}
118118

119-
pub type CelerModule = Module<TestRuntime>;
119+
pub type CelerPayModule = Module<TestRuntime>;
120120
pub type System = frame_system::Module<TestRuntime>;
121121
pub type Timestamp = pallet_timestamp::Module<TestRuntime>;
122122
type MockBooleanCondition = mock_boolean_condition::Module<TestRuntime>;

pallets/celer-pay/src/pay_registry.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{BalanceOf, PayInfoMap, Module, RawEvent};
1+
use super::{BalanceOf, PayInfoMap, Module as CelerPayModule, RawEvent};
22
use crate::traits::Trait;
33
use codec::{Decode, Encode};
44
use frame_support::{ensure, storage::StorageMap};
@@ -19,7 +19,7 @@ pub struct PayRegistry<T>(sp_std::marker::PhantomData<T>);
1919

2020
impl<T: Trait> PayRegistry<T> {
2121
pub fn calculate_pay_id(pay_hash: T::Hash) -> T::Hash {
22-
let pay_resolver_account = Module::<T>::get_pay_resolver_id();
22+
let pay_resolver_account = CelerPayModule::<T>::get_pay_resolver_id();
2323
let mut encoded = pay_hash.encode();
2424
encoded.extend(pay_resolver_account.encode());
2525
let pay_id = T::Hashing::hash(&encoded);
@@ -37,7 +37,7 @@ impl<T: Trait> PayRegistry<T> {
3737
PayInfoMap::<T>::mutate(&pay_id, |info| *info = Some(new_pay_info));
3838

3939
// Emit PayInfoUpdate event
40-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
40+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
4141
pay_id,
4242
amt,
4343
pay_info.resolve_deadline.unwrap_or(Zero::zero())
@@ -50,7 +50,7 @@ impl<T: Trait> PayRegistry<T> {
5050
PayInfoMap::<T>::insert(pay_id, new_pay_info);
5151

5252
// Emit PayInfoUpdate event
53-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
53+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
5454
pay_id,
5555
amt,
5656
Zero::zero(),
@@ -74,7 +74,7 @@ impl<T: Trait> PayRegistry<T> {
7474
PayInfoMap::<T>::mutate(&pay_id, |info| *info = Some(new_pay_info));
7575

7676
// Emit PayInfoUpdate event
77-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
77+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
7878
pay_id,
7979
pay_info.amount.unwrap_or(Zero::zero()),
8080
deadline,
@@ -87,7 +87,7 @@ impl<T: Trait> PayRegistry<T> {
8787
PayInfoMap::<T>::insert(pay_id, new_pay_info);
8888

8989
// Emit PayInfoUpdate event
90-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
90+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
9191
pay_id,
9292
Zero::zero(),
9393
deadline
@@ -110,7 +110,7 @@ impl<T: Trait> PayRegistry<T> {
110110
<PayInfoMap<T>>::mutate(&pay_id, |info| *info = Some(new_pay_info));
111111

112112
// Emit PayInfoUpdate event
113-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
113+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
114114
pay_id,
115115
amt,
116116
deadline,
@@ -139,7 +139,7 @@ impl<T: Trait> PayRegistry<T> {
139139
PayInfoMap::<T>::mutate(&pay_id, |info| *info = Some(new_pay_info));
140140

141141
// Emit PayInfoUpdate event
142-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
142+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
143143
pay_id,
144144
amts[i],
145145
pay_info.resolve_deadline.unwrap()
@@ -152,7 +152,7 @@ impl<T: Trait> PayRegistry<T> {
152152
PayInfoMap::<T>::insert(pay_id, new_pay_info);
153153

154154
// Emit PayInfoUpdate event
155-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
155+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
156156
pay_id,
157157
amts[i],
158158
Zero::zero(),
@@ -183,7 +183,7 @@ impl<T: Trait> PayRegistry<T> {
183183
PayInfoMap::<T>::mutate(&pay_id, |info| *info = Some(new_pay_info));
184184

185185
// Emit PayInfoUpdate event
186-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
186+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
187187
pay_id,
188188
pay_info.amount.unwrap(),
189189
deadlines[i],
@@ -196,7 +196,7 @@ impl<T: Trait> PayRegistry<T> {
196196
PayInfoMap::<T>::insert(pay_id, new_pay_info);
197197

198198
// Emit PayInfoUpdate event
199-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
199+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
200200
pay_id,
201201
Zero::zero(),
202202
deadlines[i],
@@ -226,7 +226,7 @@ impl<T: Trait> PayRegistry<T> {
226226
PayInfoMap::<T>::mutate(&pay_id, |info| *info = Some(new_pay_info));
227227

228228
// Emit PayInfoUpdate event
229-
Module::<T>::deposit_event(RawEvent::PayInfoUpdate(
229+
CelerPayModule::<T>::deposit_event(RawEvent::PayInfoUpdate(
230230
pay_id,
231231
amts[i],
232232
deadlines[i]

pallets/celer-pay/src/pay_resolver.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{BalanceOf, Error, Module, RawEvent};
1+
use super::{BalanceOf, Error, Module as CelerPayModule, RawEvent};
22
use crate::traits::Trait;
33
use crate::pay_registry::PayRegistry;
44
use crate::numeric_condition_caller::NumericConditionCaller;
@@ -180,12 +180,12 @@ impl<T: Trait> PayResolver<T> {
180180

181181
// Check signatures
182182
let encoded = encode_conditional_pay::<T>(pay.clone());
183-
Module::<T>::check_single_signature(
183+
CelerPayModule::<T>::check_single_signature(
184184
vouched_pay_result.sig_of_src,
185185
&encoded,
186186
pay.src.clone(),
187187
)?;
188-
Module::<T>::check_single_signature(
188+
CelerPayModule::<T>::check_single_signature(
189189
vouched_pay_result.sig_of_dest,
190190
&encoded,
191191
pay.dest.clone(),
@@ -228,7 +228,7 @@ fn resolve_payment<T: Trait>(
228228
PayRegistry::<T>::set_pay_info(pay_hash, amount, block_number)?;
229229

230230
// Emit ResolvePayment event
231-
Module::<T>::deposit_event(RawEvent::ResolvePayment(
231+
CelerPayModule::<T>::deposit_event(RawEvent::ResolvePayment(
232232
pay_id,
233233
amount,
234234
block_number
@@ -239,7 +239,7 @@ fn resolve_payment<T: Trait>(
239239
PayRegistry::<T>::set_pay_amount(pay_hash, amount)?;
240240

241241
// Emit ResolvePayment event
242-
Module::<T>::deposit_event(RawEvent::ResolvePayment(
242+
CelerPayModule::<T>::deposit_event(RawEvent::ResolvePayment(
243243
pay_id,
244244
amount,
245245
current_deadline
@@ -264,7 +264,7 @@ fn resolve_payment<T: Trait>(
264264
PayRegistry::<T>::set_pay_info(pay_hash, amount, new_deadline)?;
265265

266266
// Emit ResolvePayment event
267-
Module::<T>::deposit_event(RawEvent::ResolvePayment(
267+
CelerPayModule::<T>::deposit_event(RawEvent::ResolvePayment(
268268
pay_id,
269269
amount,
270270
new_deadline
@@ -293,7 +293,7 @@ fn calculate_boolean_and_payment<T: Trait>(
293293
ensure!(preimages[j] == hash_lock, "Wrong preimage");
294294
j = j + 1;
295295
} else if cond.condition_type == ConditionType::BooleanRuntimeModule {
296-
let pay_resolver_account = Module::<T>::get_pay_resolver_id();
296+
let pay_resolver_account = CelerPayModule::<T>::get_pay_resolver_id();
297297

298298
// call is_finalized of boolean condition
299299
let call_is_finalized = cond.call_is_finalized.unwrap();
@@ -342,7 +342,7 @@ fn calculate_boolean_or_payment<T: Trait>(
342342
ensure!(preimages[j] == hash_lock, "Wrong preimage");
343343
j += 1;
344344
} else if cond.condition_type == ConditionType::BooleanRuntimeModule {
345-
let pay_resolver_account = Module::<T>::get_pay_resolver_id();
345+
let pay_resolver_account = CelerPayModule::<T>::get_pay_resolver_id();
346346

347347
// call is_finalized of boolean_condition
348348
let call_is_finalized = cond.call_is_finalized.unwrap();
@@ -446,7 +446,7 @@ fn is_numeric_logic<T: Trait>(func_type: TransferFunctionType) -> bool {
446446

447447
// Calculate pay id
448448
pub fn calculate_pay_id<T: Trait>(pay_hash: T::Hash) -> T::Hash {
449-
let pay_resolver_account = Module::<T>::get_pay_resolver_id();
449+
let pay_resolver_account = CelerPayModule::<T>::get_pay_resolver_id();
450450
let mut encoded = pay_hash.encode();
451451
encoded.extend(pay_resolver_account.encode());
452452
let pay_id = T::Hashing::hash(&encoded);

0 commit comments

Comments
 (0)