Skip to content

Commit

Permalink
feat: add force to internal functions LSP7
Browse files Browse the repository at this point in the history
  • Loading branch information
skimaharvey committed Dec 18, 2024
1 parent 9dd2104 commit 089ee47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions packages/lsp7-contracts/contracts/LSP7DigitalAsset.sol
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,11 @@ abstract contract LSP7DigitalAsset is
revert LSP7CannotSendWithAddressZero();
}

_beforeTokenTransfer(address(0), to, amount, data);
_beforeTokenTransfer(address(0), to, amount, force, data);

_update(address(0), to, amount, force, data);

_afterTokenTransfer(address(0), to, amount, data);
_afterTokenTransfer(address(0), to, amount, force, data);

bytes memory lsp1Data = abi.encode(
msg.sender,
Expand Down Expand Up @@ -650,11 +650,11 @@ abstract contract LSP7DigitalAsset is
revert LSP7CannotSendWithAddressZero();
}

_beforeTokenTransfer(from, address(0), amount, data);
_beforeTokenTransfer(from, address(0), amount, false, data);

_update(from, address(0), amount, false, data);

_afterTokenTransfer(from, address(0), amount, data);
_afterTokenTransfer(from, address(0), amount, false, data);

bytes memory lsp1Data = abi.encode(
msg.sender,
Expand Down Expand Up @@ -745,11 +745,11 @@ abstract contract LSP7DigitalAsset is
revert LSP7CannotSendWithAddressZero();
}

_beforeTokenTransfer(from, to, amount, data);
_beforeTokenTransfer(from, to, amount, force, data);

_update(from, to, amount, force, data);

_afterTokenTransfer(from, to, amount, data);
_afterTokenTransfer(from, to, amount, force, data);

bytes memory lsp1Data = abi.encode(msg.sender, from, to, amount, data);

Expand Down Expand Up @@ -814,12 +814,14 @@ abstract contract LSP7DigitalAsset is
* @param from The sender address
* @param to The recipient address
* @param amount The amount of token to transfer
* @param force A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not.
* @param data The data sent alongside the transfer
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount,
bool force,
bytes memory data // solhint-disable-next-line no-empty-blocks
) internal virtual {}

Expand All @@ -830,12 +832,14 @@ abstract contract LSP7DigitalAsset is
* @param from The sender address
* @param to The recipient address
* @param amount The amount of token to transfer
* @param force A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not.
* @param data The data sent alongside the transfer
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount,
bool force,
bytes memory data // solhint-disable-next-line no-empty-blocks
) internal virtual {}

Expand Down
16 changes: 10 additions & 6 deletions packages/lsp7-contracts/contracts/LSP7DigitalAssetInitAbstract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,11 @@ abstract contract LSP7DigitalAssetInitAbstract is
revert LSP7CannotSendWithAddressZero();
}

_beforeTokenTransfer(address(0), to, amount, data);
_beforeTokenTransfer(address(0), to, amount, force, data);

_update(address(0), to, amount, force, data);

_afterTokenTransfer(address(0), to, amount, data);
_afterTokenTransfer(address(0), to, amount, force, data);

bytes memory lsp1Data = abi.encode(
msg.sender,
Expand Down Expand Up @@ -663,11 +663,11 @@ abstract contract LSP7DigitalAssetInitAbstract is
revert LSP7CannotSendWithAddressZero();
}

_beforeTokenTransfer(from, address(0), amount, data);
_beforeTokenTransfer(from, address(0), amount, false, data);

_update(from, address(0), amount, false, data);

_afterTokenTransfer(from, address(0), amount, data);
_afterTokenTransfer(from, address(0), amount, false, data);

bytes memory lsp1Data = abi.encode(
msg.sender,
Expand Down Expand Up @@ -758,11 +758,11 @@ abstract contract LSP7DigitalAssetInitAbstract is
revert LSP7CannotSendWithAddressZero();
}

_beforeTokenTransfer(from, to, amount, data);
_beforeTokenTransfer(from, to, amount, force, data);

_update(from, to, amount, force, data);

_afterTokenTransfer(from, to, amount, data);
_afterTokenTransfer(from, to, amount, force, data);

bytes memory lsp1Data = abi.encode(msg.sender, from, to, amount, data);

Expand Down Expand Up @@ -827,12 +827,14 @@ abstract contract LSP7DigitalAssetInitAbstract is
* @param from The sender address
* @param to The recipient address
* @param amount The amount of token to transfer
* @param force A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not.
* @param data The data sent alongside the transfer
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount,
bool force,
bytes memory data // solhint-disable-next-line no-empty-blocks
) internal virtual {}

Expand All @@ -843,12 +845,14 @@ abstract contract LSP7DigitalAssetInitAbstract is
* @param from The sender address
* @param to The recipient address
* @param amount The amount of token to transfer
* @param force A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not.
* @param data The data sent alongside the transfer
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount,
bool force,
bytes memory data // solhint-disable-next-line no-empty-blocks
) internal virtual {}

Expand Down

0 comments on commit 089ee47

Please sign in to comment.