Skip to content

Commit

Permalink
fix: rename nester to depositor, add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrshiposha committed Oct 16, 2023
1 parent a97dd3a commit 48b3789
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
12 changes: 7 additions & 5 deletions pallets/fungible/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,16 @@ impl<T: Config> Pallet<T> {
amount: u128,
nesting_budget: &dyn Budget,
) -> DispatchResultWithPostInfo {
let nester = from;

Self::transfer_internal(collection, nester, from, to, amount, nesting_budget)
let depositor = from;
Self::transfer_internal(collection, depositor, from, to, amount, nesting_budget)
}

/// Transfers tokens from the `from` account to the `to` account.
/// The `depositor` is the account who deposits the tokens.
/// For instance, the nesting rules will be checked against the `depositor`'s permissions.
fn transfer_internal(
collection: &FungibleHandle<T>,
nester: &T::CrossAccountId,
depositor: &T::CrossAccountId,
from: &T::CrossAccountId,
to: &T::CrossAccountId,
amount: u128,
Expand Down Expand Up @@ -429,7 +431,7 @@ impl<T: Config> Pallet<T> {
// from != to && amount != 0

<PalletStructure<T>>::nest_if_sent_to_token(
nester,
depositor,
to,
collection.id,
TokenId::default(),
Expand Down
12 changes: 7 additions & 5 deletions pallets/nonfungible/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,14 +718,16 @@ impl<T: Config> Pallet<T> {
token: TokenId,
nesting_budget: &dyn Budget,
) -> DispatchResultWithPostInfo {
let nester = from;

Self::transfer_internal(collection, nester, from, to, token, nesting_budget)
let depositor = from;
Self::transfer_internal(collection, depositor, from, to, token, nesting_budget)
}

/// Transfers an NFT from the `from` account to the `to` account.
/// The `depositor` is the account who deposits the NFT.
/// For instance, the nesting rules will be checked against the `depositor`'s permissions.
pub fn transfer_internal(
collection: &NonfungibleHandle<T>,
nester: &T::CrossAccountId,
depositor: &T::CrossAccountId,
from: &T::CrossAccountId,
to: &T::CrossAccountId,
token: TokenId,
Expand Down Expand Up @@ -767,7 +769,7 @@ impl<T: Config> Pallet<T> {
};

<PalletStructure<T>>::nest_if_sent_to_token(
nester,
depositor,
to,
collection.id,
token,
Expand Down
20 changes: 15 additions & 5 deletions pallets/refungible/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,24 @@ impl<T: Config> Pallet<T> {
amount: u128,
nesting_budget: &dyn Budget,
) -> DispatchResult {
let nester = from;

Self::transfer_internal(collection, nester, from, to, token, amount, nesting_budget)
let depositor = from;
Self::transfer_internal(
collection,
depositor,
from,
to,
token,
amount,
nesting_budget,
)
}

/// Transfers RFT tokens from the `from` account to the `to` account.
/// The `depositor` is the account who deposits the tokens.
/// For instance, the nesting rules will be checked against the `depositor`'s permissions.
pub fn transfer_internal(
collection: &RefungibleHandle<T>,
nester: &T::CrossAccountId,
depositor: &T::CrossAccountId,
from: &T::CrossAccountId,
to: &T::CrossAccountId,
token: TokenId,
Expand Down Expand Up @@ -697,7 +707,7 @@ impl<T: Config> Pallet<T> {
// from != to && amount != 0

<PalletStructure<T>>::nest_if_sent_to_token(
nester,
depositor,
to,
collection.id,
token,
Expand Down

0 comments on commit 48b3789

Please sign in to comment.