Skip to content

Commit

Permalink
fix(protocol): revert adding batchBurn to IBridgedERC1155 (#17077)
Browse files Browse the repository at this point in the history
Co-authored-by: dantaik <[email protected]>
  • Loading branch information
dantaik and dantaik authored May 10, 2024
1 parent b7bd29c commit 4903bec
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/protocol/contracts/tokenvault/BridgedERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ contract BridgedERC1155 is
}

/// @inheritdoc IBridgedERC1155
function burnBatch(
uint256[] calldata _ids,
uint256[] calldata _amounts
function burn(
uint256 _id,
uint256 _amount
)
external
whenNotPaused
onlyFromNamed(LibStrings.B_ERC1155_VAULT)
nonReentrant
{
_burnBatch(msg.sender, _ids, _amounts);
_burn(msg.sender, _id, _amount);
}

/// @inheritdoc IBridgedERC1155
Expand Down
4 changes: 3 additions & 1 deletion packages/protocol/contracts/tokenvault/ERC1155Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ contract ERC1155Vault is BaseNFTVault, ERC1155ReceiverUpgradeable {
IERC1155(_op.token).safeBatchTransferFrom(
msg.sender, address(this), _op.tokenIds, _op.amounts, ""
);
IBridgedERC1155(_op.token).burnBatch(_op.tokenIds, _op.amounts);
for (uint256 i; i < _op.tokenIds.length; ++i) {
IBridgedERC1155(_op.token).burn(_op.tokenIds[i], _op.amounts[i]);
}
} else {
// is a ctoken token, meaning, it lives on this chain
ctoken_ = CanonicalNFT({
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/contracts/tokenvault/IBridgedERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ interface IBridgedERC1155 {
)
external;

/// @dev Batch burns tokens.
/// @param _ids Array of IDs of the tokens to burn.
/// @param _amounts Amount of tokens to burn respectively.
function burnBatch(uint256[] calldata _ids, uint256[] calldata _amounts) external;
/// @dev Burns tokens.
/// @param _id ID of the token to burn.
/// @param _amount Amount of token to burn respectively.
function burn(uint256 _id, uint256 _amount) external;

/// @notice Gets the canonical token's address and chain ID.
/// @return The canonical token's address.
Expand Down
4 changes: 1 addition & 3 deletions packages/protocol/test/tokenvault/ERC1155Vault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -975,11 +975,9 @@ contract ERC1155VaultTest is TaikoTest {
destChainErc1155Vault.sendToken{ value: GAS_LIMIT }(sendOpts);

// Also Vault cannot burn tokens it does not own (even if the priv key compromised)
uint256[] memory randomIdAndLength = new uint256[](1);
randomIdAndLength[0] = 20;
vm.prank(address(destChainErc1155Vault), address(destChainErc1155Vault));
vm.expectRevert("ERC1155: burn amount exceeds balance");
BridgedERC1155(deployedContract).burnBatch(randomIdAndLength, randomIdAndLength);
BridgedERC1155(deployedContract).burn(1, 20);

// After setApprovalForAll() ERC1155Vault can transfer and burn
vm.prank(Alice, Alice);
Expand Down

0 comments on commit 4903bec

Please sign in to comment.