Skip to content

Commit

Permalink
might need different endpoint entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
amiecorso committed Mar 6, 2024
1 parent fd34ba0 commit 4cbf69f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
6 changes: 4 additions & 2 deletions contracts/Removal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ contract Removal is
*
* ##### Requirements:
*
* - Can only be called by the Market contract.
* - Can only be called by the Market contract or an account with the `CONSIGNOR_ROLE`.
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
Expand All @@ -636,7 +636,9 @@ contract Removal is
uint256[] memory amounts,
bytes memory data
) public override {
if (_msgSender() != address(_market)) {
if (
_msgSender() != address(_market) && !hasRole(CONSIGNOR_ROLE, _msgSender())
) {
revert ForbiddenTransfer();
}
super.safeBatchTransferFrom({
Expand Down
48 changes: 23 additions & 25 deletions test/Removal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1330,55 +1330,53 @@ contract Removal__beforeTokenTransfer is NonUpgradeableRemoval {
}
}

contract Removal_safeTransferFrom_reverts_ForbiddenTransfer is
UpgradeableMarket
{
contract Removal_safeBatchTransferFrom is UpgradeableMarket {
uint256[] private _removalIds;

function setUp() external {
_removalIds = _seedRemovals({
to: _namedAccounts.supplier,
count: 1,
count: 2,
list: false
});
}

function test() external {
function test_reverts_ForbiddenTransfer() external {
vm.expectRevert(ForbiddenTransfer.selector);
vm.prank(_namedAccounts.supplier);
_removal.safeTransferFrom({
_removal.safeBatchTransferFrom({
from: _namedAccounts.supplier,
to: _namedAccounts.supplier2,
id: _removalIds[0],
amount: 1 ether,
ids: _removalIds,
amounts: new uint256[](2).fill(1 ether),
data: ""
});
}
}

contract Removal_safeBatchTransferFrom_reverts_ForbiddenTransfer is
UpgradeableMarket
{
uint256[] private _removalIds;

function setUp() external {
_removalIds = _seedRemovals({
to: _namedAccounts.supplier,
count: 2,
list: false
});
}

function test() external {
function test_isCallableByConsignor() external {
vm.expectRevert(ForbiddenTransfer.selector);
vm.prank(_namedAccounts.supplier);
vm.prank(_namedAccounts.admin);
_removal.safeBatchTransferFrom({
from: _namedAccounts.supplier,
to: _namedAccounts.supplier2,
to: _namedAccounts.admin,
ids: _removalIds,
amounts: new uint256[](2).fill(1 ether),
data: ""
});
_removal.grantRole({
role: _removal.CONSIGNOR_ROLE(),
account: _namedAccounts.admin
});
vm.prank(_namedAccounts.admin);
_removal.safeBatchTransferFrom({
from: _namedAccounts.supplier,
to: _namedAccounts.admin,
ids: _removalIds,
amounts: new uint256[](2).fill(1 ether),
data: ""
});
assertEq(_removal.balanceOf(_namedAccounts.admin, _removalIds[0]), 1 ether);
assertEq(_removal.balanceOf(_namedAccounts.admin, _removalIds[1]), 1 ether);
}
}

Expand Down
14 changes: 10 additions & 4 deletions test/tasks/vesting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const MOCK_GITHUB_VESTING_GRANTS = [
'0xBd6E6A75c7A51cfdf08DDf2f538ceB221835839b',
'daf2922b-c96d-442e-a267-e977758961f1',
'50000',
'2023-03-03T00:00:00Z',
dateLessThanOneYearAgoFromTodayISOString,
'2027-03-03T00:00:00Z',
'2028-03-03T00:00:00Z',
'2024-03-03T00:00:00Z',
Expand Down Expand Up @@ -171,7 +171,7 @@ const MOCK_GITHUB_VESTING_GRANTS = [
'0x6029424b26feFfe2879E88C62e8130dC418e64D9',
'6a36b897-b38d-4938-9537-32a5ee4f33b8',
'52000',
'2023-03-10T00:00:00Z',
dateLessThanOneYearAgoFromTodayISOString,
'2028-03-10T00:00:00Z',
'2029-03-10T00:00:00Z',
'2025-03-10T00:00:00Z',
Expand Down Expand Up @@ -980,7 +980,10 @@ describe('vesting task', () => {
},
'0xBd6E6A75c7A51cfdf08DDf2f538ceB221835839b': {
vestEndTime: { __old: 0, __new: 1_804_032_000 },
startTime: { __old: 0, __new: 1_677_801_600 },
startTime: {
__old: 0,
__new: utcToEvmTime(dateLessThanOneYearAgoFromTodayUnix),
},
originalAmount: {
__old: '0',
__new: '50000000000000000000000',
Expand Down Expand Up @@ -1028,7 +1031,10 @@ describe('vesting task', () => {
},
'0x6029424b26feFfe2879E88C62e8130dC418e64D9': {
vestEndTime: { __old: 0, __new: 1_836_259_200 },
startTime: { __old: 0, __new: 1_678_406_400 },
startTime: {
__old: 0,
__new: utcToEvmTime(dateLessThanOneYearAgoFromTodayUnix),
},
originalAmount: {
__old: '0',
__new: '52000000000000000000000',
Expand Down

0 comments on commit 4cbf69f

Please sign in to comment.