Skip to content

Commit 054d2f1

Browse files
committed
(!) pack content fix bug
1 parent bc278d6 commit 054d2f1

3 files changed

Lines changed: 508 additions & 4 deletions

File tree

src/extension/TokenStore.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
77
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
88
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
99
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
10+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
1011
import { TokenBundle, ITokenBundle } from "./TokenBundle.sol";
1112

1213
contract TokenStore is TokenBundle, ERC721Holder, ERC1155Holder {
14+
using SafeERC20 for IERC20;
1315

1416
/// @dev Store / escrow multiple ERC1155, ERC721, ERC20 tokens.
1517
function _storeTokens(
@@ -40,7 +42,11 @@ contract TokenStore is TokenBundle, ERC721Holder, ERC1155Holder {
4042
/// @dev Transfers an arbitrary ERC20 / ERC721 / ERC1155 token.
4143
function _transferToken(address _from, address _to, Token memory _token) internal {
4244
if (_token.tokenType == TokenType.ERC20) {
43-
IERC20(_token.assetContract).transferFrom(_from, _to, _token.totalAmount);
45+
if(_from == address(this)) {
46+
IERC20(_token.assetContract).transfer(_to, _token.totalAmount);
47+
} else {
48+
IERC20(_token.assetContract).safeTransferFrom(_from, _to, _token.totalAmount);
49+
}
4450
} else if (_token.tokenType == TokenType.ERC721) {
4551
IERC721(_token.assetContract).safeTransferFrom(_from, _to, _token.tokenId);
4652
} else if (_token.tokenType == TokenType.ERC1155) {

src/pack/BicPack.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
99
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
1010
import {TokenStore} from "../extension/TokenStore.sol";
1111

12-
contract Pack is ERC1155, Ownable, ReentrancyGuard, TokenStore {
12+
contract BicPack is ERC1155, Ownable, ReentrancyGuard, TokenStore {
1313
struct PackInfo {
1414
uint256[] perUnitAmounts;
1515
uint128 openStartTimestamp;
@@ -123,8 +123,6 @@ contract Pack is ERC1155, Ownable, ReentrancyGuard, TokenStore {
123123
/// @notice Lets a pack owner open packs and receive the packs' reward units.
124124
function openPack(uint256 _packId, uint256 _amountToOpen) external nonReentrant returns (Token[] memory) {
125125
address opener = _msgSender();
126-
127-
require(opener == tx.origin, "!EOA");
128126
require(balanceOf(opener, _packId) >= _amountToOpen, "!Bal");
129127

130128
PackInfo memory pack = packInfo[_packId];

0 commit comments

Comments
 (0)