From a402e746f47dae884d47e0195515ebf8db098885 Mon Sep 17 00:00:00 2001 From: Maxime Date: Wed, 18 Dec 2024 10:38:05 +0000 Subject: [PATCH] feat: add force to internal functions LSP7 --- .../contracts/LSP7DigitalAsset.sol | 18 +++++++++++------- .../contracts/LSP7DigitalAssetInitAbstract.sol | 18 +++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/lsp7-contracts/contracts/LSP7DigitalAsset.sol b/packages/lsp7-contracts/contracts/LSP7DigitalAsset.sol index 2f9d8c985..cbbb3857e 100644 --- a/packages/lsp7-contracts/contracts/LSP7DigitalAsset.sol +++ b/packages/lsp7-contracts/contracts/LSP7DigitalAsset.sol @@ -600,7 +600,7 @@ abstract contract LSP7DigitalAsset is revert LSP7CannotSendWithAddressZero(); } - _beforeTokenTransfer(address(0), to, amount, data); + _beforeTokenTransfer(address(0), to, amount, force, data); // tokens being minted _existingTokens += amount; @@ -616,7 +616,7 @@ abstract contract LSP7DigitalAsset is data: data }); - _afterTokenTransfer(address(0), to, amount, data); + _afterTokenTransfer(address(0), to, amount, force, data); bytes memory lsp1Data = abi.encode( msg.sender, @@ -662,7 +662,7 @@ abstract contract LSP7DigitalAsset is revert LSP7CannotSendWithAddressZero(); } - _beforeTokenTransfer(from, address(0), amount, data); + _beforeTokenTransfer(from, address(0), amount, false, data); uint256 balance = _tokenOwnerBalances[from]; if (amount > balance) { @@ -682,7 +682,7 @@ abstract contract LSP7DigitalAsset is data: data }); - _afterTokenTransfer(from, address(0), amount, data); + _afterTokenTransfer(from, address(0), amount, false, data); bytes memory lsp1Data = abi.encode( msg.sender, @@ -773,11 +773,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); @@ -834,7 +834,7 @@ abstract contract LSP7DigitalAsset is data: data }); - _afterTokenTransfer(from, to, amount, data); + _afterTokenTransfer(from, to, amount, force, data); bytes memory lsp1Data = abi.encode(msg.sender, from, to, amount, data); @@ -849,12 +849,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 {} @@ -865,12 +867,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 {} diff --git a/packages/lsp7-contracts/contracts/LSP7DigitalAssetInitAbstract.sol b/packages/lsp7-contracts/contracts/LSP7DigitalAssetInitAbstract.sol index f4c817705..4d6329374 100644 --- a/packages/lsp7-contracts/contracts/LSP7DigitalAssetInitAbstract.sol +++ b/packages/lsp7-contracts/contracts/LSP7DigitalAssetInitAbstract.sol @@ -613,7 +613,7 @@ abstract contract LSP7DigitalAssetInitAbstract is revert LSP7CannotSendWithAddressZero(); } - _beforeTokenTransfer(address(0), to, amount, data); + _beforeTokenTransfer(address(0), to, amount, force, data); // tokens being minted _existingTokens += amount; @@ -629,7 +629,7 @@ abstract contract LSP7DigitalAssetInitAbstract is data: data }); - _afterTokenTransfer(address(0), to, amount, data); + _afterTokenTransfer(address(0), to, amount, force, data); bytes memory lsp1Data = abi.encode( msg.sender, @@ -675,7 +675,7 @@ abstract contract LSP7DigitalAssetInitAbstract is revert LSP7CannotSendWithAddressZero(); } - _beforeTokenTransfer(from, address(0), amount, data); + _beforeTokenTransfer(from, address(0), amount, false, data); uint256 balance = _tokenOwnerBalances[from]; if (amount > balance) { @@ -695,7 +695,7 @@ abstract contract LSP7DigitalAssetInitAbstract is data: data }); - _afterTokenTransfer(from, address(0), amount, data); + _afterTokenTransfer(from, address(0), amount, false, data); bytes memory lsp1Data = abi.encode( msg.sender, @@ -786,11 +786,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); @@ -847,7 +847,7 @@ abstract contract LSP7DigitalAssetInitAbstract is data: data }); - _afterTokenTransfer(from, to, amount, data); + _afterTokenTransfer(from, to, amount, force, data); bytes memory lsp1Data = abi.encode(msg.sender, from, to, amount, data); @@ -862,12 +862,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 {} @@ -878,12 +880,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 {}