Code to reproduce
I write my own contract Inheritance from ERC1155.
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
how can i use _asSingletonArray function. i need it to build my own _beforeTokenTransfer hook . but i can use this function because they are private and can not be overwrite
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
contract MyContract is ERC1155 {
function xxx(){
_beforeTokenTransfer(
operator,
operator,
address(0),
_asSingletonArray(_tokenId), //i want to use this function here
_asSingletonArray(_balance),
""
);
}
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data); // Call parent hook
.......... // my logic below
}
function _asSingletonArray(uint256 element) //can't be override here , So how can i conveniently use the function
private
pure
override
virtual
returns (uint256[] memory)
{
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}